From: Sami Kerola Date: Wed, 29 Feb 2012 14:49:47 +0000 (+0100) Subject: include: add asprintf wrapper X-Git-Tag: v2.22-rc1~657 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eeb31db9b9727f8851ba89970c80787b420ad6d8;p=thirdparty%2Futil-linux.git include: add asprintf wrapper Signed-off-by: Sami Kerola --- diff --git a/include/xalloc.h b/include/xalloc.h index feeb1144f9..8c22ff76a9 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