]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
include/xalloc: add xvasprintf()
authorKarel Zak <kzak@redhat.com>
Thu, 9 Jan 2014 13:48:49 +0000 (14:48 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 11 Mar 2014 10:35:13 +0000 (11:35 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
include/xalloc.h

index 105d713b15d66b27ba0710cb2c3257850881b0df..f012fb2946d3bd6790694f644f1f95e86c5f8914 100644 (file)
@@ -91,6 +91,14 @@ static inline int __attribute__ ((__format__(printf, 2, 3)))
        return ret;
 }
 
+static inline int xvasprintf(char **strp, const char *fmt, va_list ap)
+{
+       int ret = vasprintf(&(*strp), fmt, ap);
+       if (ret < 0)
+               err(XALLOC_EXIT_CODE, "cannot allocate string");
+       return ret;
+}
+
 
 static inline char * __attribute__((warn_unused_result)) xgethostname(void)
 {