From: Masatake YAMATO Date: Mon, 7 Mar 2022 13:07:21 +0000 (+0900) Subject: lsfd: move xstrappend and xstrputc to lsfd.h X-Git-Tag: v2.39-rc1~709^2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fd79de87208f94d9588315244cfc882c565d1668;p=thirdparty%2Futil-linux.git lsfd: move xstrappend and xstrputc to lsfd.h Signed-off-by: Masatake YAMATO --- diff --git a/misc-utils/lsfd.c b/misc-utils/lsfd.c index 6614a889d4..8d593fa279 100644 --- a/misc-utils/lsfd.c +++ b/misc-utils/lsfd.c @@ -305,9 +305,6 @@ struct lsfd_control { struct lsfd_counter **counters; /* NULL terminated array. */ }; -static void xstrappend(char **a, const char *b); -static void xstrputc(char **a, char c); - static int column_name_to_id(const char *name, size_t namesz) { size_t i; @@ -1342,18 +1339,6 @@ static void __attribute__((__noreturn__)) usage(void) exit(EXIT_SUCCESS); } -static void xstrappend(char **a, const char *b) -{ - if (strappend(a, b) < 0) - err(EXIT_FAILURE, _("failed to allocate memory for string")); -} - -static void xstrputc(char **a, char c) -{ - char b[] = {c, '\0'}; - xstrappend(a, b); -} - static void append_filter_expr(char **a, const char *b, bool and) { if (*a == NULL) { diff --git a/misc-utils/lsfd.h b/misc-utils/lsfd.h index ec8f40cfb5..cf2cb52b30 100644 --- a/misc-utils/lsfd.h +++ b/misc-utils/lsfd.h @@ -30,6 +30,7 @@ #include #include "list.h" +#include "strutils.h" /* * column IDs @@ -181,4 +182,16 @@ const char *get_chrdrv(unsigned long major); const char *get_miscdev(unsigned long minor); const char *get_nodev_filesystem(unsigned long minor); +static inline void xstrappend(char **a, const char *b) +{ + if (strappend(a, b) < 0) + err(XALLOC_EXIT_CODE, _("failed to allocate memory for string")); +} + +static inline void xstrputc(char **a, char c) +{ + char b[] = {c, '\0'}; + xstrappend(a, b); +} + #endif /* UTIL_LINUX_LSFD_H */