diff options
author | Karel Zak | 2014-01-09 14:48:49 +0100 |
---|---|---|
committer | Karel Zak | 2014-03-11 11:35:13 +0100 |
commit | 2e6c3a53f9fb5d8bbebe88951f3e0ddefb5ca429 (patch) | |
tree | 0e498c9b358c04332bc3df1efca9f11f2e9c20e2 /include/xalloc.h | |
parent | libfdisk: add fdisk_table_get_nents() (diff) | |
download | kernel-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.h | 8 |
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) { |