summaryrefslogtreecommitdiffstats
path: root/include/xalloc.h
diff options
context:
space:
mode:
authorSami Kerola2012-02-29 15:49:47 +0100
committerSami Kerola2012-03-18 14:28:05 +0100
commiteeb31db9b9727f8851ba89970c80787b420ad6d8 (patch)
treeab435e783f4030bfd19c06c999e4b409b39a3db6 /include/xalloc.h
parentdocs: TODO removal, ldattach usage is done (diff)
downloadkernel-qcow2-util-linux-eeb31db9b9727f8851ba89970c80787b420ad6d8.tar.gz
kernel-qcow2-util-linux-eeb31db9b9727f8851ba89970c80787b420ad6d8.tar.xz
kernel-qcow2-util-linux-eeb31db9b9727f8851ba89970c80787b420ad6d8.zip
include: add asprintf wrapper
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'include/xalloc.h')
-rw-r--r--include/xalloc.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/xalloc.h b/include/xalloc.h
index feeb1144f..8c22ff76a 100644
--- a/include/xalloc.h
+++ b/include/xalloc.h
@@ -63,4 +63,15 @@ static inline char *xstrdup(const char *str)
return ret;
}
+static inline int xasprintf(char **strp, char *fmt, ...)
+{
+ int ret;
+ va_list args;
+ va_start(args, fmt);
+ ret = vasprintf(&(*strp), fmt, args);
+ va_end(args);
+ if (ret < 0)
+ err(XALLOC_EXIT_CODE, "cannot allocate string");
+ return ret;
+}
#endif