summaryrefslogtreecommitdiffstats
path: root/include/xalloc.h
diff options
context:
space:
mode:
authorKarel Zak2014-01-09 14:48:49 +0100
committerKarel Zak2014-03-11 11:35:13 +0100
commit2e6c3a53f9fb5d8bbebe88951f3e0ddefb5ca429 (patch)
tree0e498c9b358c04332bc3df1efca9f11f2e9c20e2 /include/xalloc.h
parentlibfdisk: add fdisk_table_get_nents() (diff)
downloadkernel-qcow2-util-linux-2e6c3a53f9fb5d8bbebe88951f3e0ddefb5ca429.tar.gz
kernel-qcow2-util-linux-2e6c3a53f9fb5d8bbebe88951f3e0ddefb5ca429.tar.xz
kernel-qcow2-util-linux-2e6c3a53f9fb5d8bbebe88951f3e0ddefb5ca429.zip
include/xalloc: add xvasprintf()
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'include/xalloc.h')
-rw-r--r--include/xalloc.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/include/xalloc.h b/include/xalloc.h
index 105d713b1..f012fb294 100644
--- a/include/xalloc.h
+++ b/include/xalloc.h
@@ -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)
{