diff options
author | Sami Kerola | 2012-02-29 15:49:47 +0100 |
---|---|---|
committer | Sami Kerola | 2012-03-18 14:28:05 +0100 |
commit | eeb31db9b9727f8851ba89970c80787b420ad6d8 (patch) | |
tree | ab435e783f4030bfd19c06c999e4b409b39a3db6 /include/xalloc.h | |
parent | docs: TODO removal, ldattach usage is done (diff) | |
download | kernel-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.h | 11 |
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 |