]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsfd: add xstrfappend and xstrvfappend
authorMasatake YAMATO <yamato@redhat.com>
Fri, 29 Sep 2023 20:26:48 +0000 (05:26 +0900)
committerMasatake YAMATO <yamato@redhat.com>
Fri, 29 Sep 2023 20:29:15 +0000 (05:29 +0900)
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
misc-utils/lsfd.h

index 7a5034e255459434444aeb89b0babd041e1c7747..8cddc59ef25f06449fc3a8387ddf972962b1a1bd 100644 (file)
@@ -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
  */