summaryrefslogtreecommitdiffhomepage
path: root/util.h
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2021-04-27 12:43:38 +0200
committerGitHub <noreply@github.com>2021-04-27 12:43:38 +0200
commit8469c4b1be228f42c46f08852f028f7801b93cc9 (patch)
treef61121e8f89e39787a960e621fc8492e57fc4bc0 /util.h
parentf360350bd874aeec0806c8df02c7a20a54c44406 (diff)
parent64eec7f90e945696572ee076b75d1f35e8f2248a (diff)
Merge pull request #5 from jow-/new-type-system
New type system
Diffstat (limited to 'util.h')
-rw-r--r--util.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/util.h b/util.h
index b7029cc..c4ea087 100644
--- a/util.h
+++ b/util.h
@@ -218,6 +218,7 @@ static inline struct json_tokener *xjs_new_tokener(void) {
return tok;
}
+__attribute__((format(printf, 2, 0)))
static inline int xasprintf(char **strp, const char *fmt, ...) {
va_list ap;
int len;
@@ -234,6 +235,7 @@ static inline int xasprintf(char **strp, const char *fmt, ...) {
return len;
}
+__attribute__((format(printf, 2, 0)))
static inline int xvasprintf(char **strp, const char *fmt, va_list ap) {
int len = vasprintf(strp, fmt, ap);
@@ -245,4 +247,15 @@ static inline int xvasprintf(char **strp, const char *fmt, va_list ap) {
return len;
}
+static inline struct printbuf *xprintbuf_new(void) {
+ struct printbuf *pb = printbuf_new();
+
+ if (!pb) {
+ fprintf(stderr, "Out of memory\n");
+ abort();
+ }
+
+ return pb;
+}
+
#endif /* __UTIL_H_ */