From: Masatake YAMATO Date: Fri, 29 Sep 2023 20:26:48 +0000 (+0900) Subject: lsfd: add xstrfappend and xstrvfappend X-Git-Tag: v2.40-rc1~224^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ae3a6367fda8bd0ecae5ae46d25c85d797e4c678;p=thirdparty%2Futil-linux.git lsfd: add xstrfappend and xstrvfappend Signed-off-by: Masatake YAMATO --- diff --git a/misc-utils/lsfd.h b/misc-utils/lsfd.h index 7a5034e255..8cddc59ef2 100644 --- a/misc-utils/lsfd.h +++ b/misc-utils/lsfd.h @@ -284,6 +284,32 @@ static inline void xstrputc(char **a, char c) xstrappend(a, b); } +static inline +__attribute__((__format__(printf, 2, 0))) +int xstrvfappend(char **a, const char *format, va_list ap) +{ + int ret = strvfappend(a, format, ap); + + if (ret < 0) + err(XALLOC_EXIT_CODE, "cannot allocate string"); + return ret; + +} + +static inline +__attribute__ ((__format__ (__printf__, 2, 3))) +int xstrfappend(char **a, const char *format, ...) +{ + va_list ap; + int ret; + + va_start(ap, format); + ret = xstrvfappend(a, format, ap); + va_end(ap); + + return ret; +} + /* * Net namespace */