From 5f4c1542de2ba6106b9edf247f07055ba6922fbb Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 16 Dec 2014 11:30:53 +0100 Subject: [PATCH] lib/util: provide a dbgtext_va() function which takes va_list Signed-off-by: Stefan Metzmacher Reviewed-by: Amitay Isaacs --- lib/util/debug.c | 24 +++++++++++++++++++----- lib/util/debug.h | 1 + 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/lib/util/debug.c b/lib/util/debug.c index 750ad259759..b050205bf10 100644 --- a/lib/util/debug.c +++ b/lib/util/debug.c @@ -1063,17 +1063,14 @@ full: ***************************************************************************/ - bool dbgtext( const char *format_str, ... ) +static inline bool __dbgtext_va(const char *format_str, va_list ap) PRINTF_ATTRIBUTE(1,0); +static inline bool __dbgtext_va(const char *format_str, va_list ap) { - va_list ap; char *msgbuf = NULL; bool ret = true; int res; - va_start(ap, format_str); res = vasprintf(&msgbuf, format_str, ap); - va_end(ap); - if (res != -1) { format_debug_text(msgbuf); } else { @@ -1082,3 +1079,20 @@ full: SAFE_FREE(msgbuf); return ret; } + +bool dbgtext_va(const char *format_str, va_list ap) +{ + return __dbgtext_va(format_str, ap); +} + +bool dbgtext(const char *format_str, ... ) +{ + va_list ap; + bool ret; + + va_start(ap, format_str); + ret = __dbgtext_va(format_str, ap); + va_end(ap); + + return ret; +} diff --git a/lib/util/debug.h b/lib/util/debug.h index 27c319b760d..67d122f1bc1 100644 --- a/lib/util/debug.h +++ b/lib/util/debug.h @@ -42,6 +42,7 @@ #define MAX_DEBUG_LEVEL 1000 #endif +bool dbgtext_va(const char *, va_list ap) PRINTF_ATTRIBUTE(1,0); bool dbgtext( const char *, ... ) PRINTF_ATTRIBUTE(1,2); bool dbghdrclass( int level, int cls, const char *location, const char *func); bool dbghdr( int level, const char *location, const char *func); -- 2.34.1