From 2e6c3a53f9fb5d8bbebe88951f3e0ddefb5ca429 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 9 Jan 2014 14:48:49 +0100 Subject: include/xalloc: add xvasprintf() Signed-off-by: Karel Zak --- include/xalloc.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include/xalloc.h') 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) { -- cgit v1.2.3-55-g7522