From fddd93edbdbf8c5afbfdb3c01d82e082a8a82d1a Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 5 Feb 2026 13:36:27 +0100 Subject: libbb: introduce and use xasprintf_inplace() function old new delta xasprintf_and_free - 49 +49 watch_main 269 282 +13 singlemount 1313 1315 +2 append_mount_options 157 149 -8 ip_port_str 122 112 -10 lsblk_main 869 858 -11 add_cmd 1178 1167 -11 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 2/4 up/down: 64/-40) Total: 24 bytes Signed-off-by: Denys Vlasenko --- include/libbb.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/libbb.h') diff --git a/include/libbb.h b/include/libbb.h index 7cca925b9..6ce01ea94 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -950,6 +950,8 @@ int bb_putchar(int ch) FAST_FUNC; int bb_putchar_stderr(char ch) FAST_FUNC; int fputs_stdout(const char *s) FAST_FUNC; char *xasprintf(const char *format, ...) __attribute__ ((format(printf, 1, 2))) FAST_FUNC RETURNS_MALLOC; +char *xasprintf_and_free(char *allocated, const char *format, ...) __attribute__ ((format(printf, 2, 3))) FAST_FUNC RETURNS_MALLOC; +#define xasprintf_inplace(allocated, ...) ((allocated) = xasprintf_and_free((allocated), __VA_ARGS__)) char *auto_string(char *str) FAST_FUNC; // gcc-4.1.1 still isn't good enough at optimizing it // (+200 bytes compared to macro) -- cgit v1.2.3-55-g6feb