@@ -15,7 +15,6 @@
#define _GNU_SOURCE
#include <stdio.h>
#include <ctype.h>
-#include <stdarg.h>
#include <stdbool.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -42,20 +41,30 @@ void *btd_malloc(size_t size)
return NULL;
}
+void util_debug_va(util_debug_func_t function, void *user_data,
+ const char *format, va_list va)
+{
+ char str[78];
+
+ if (!function || !format)
+ return;
+
+ vsnprintf(str, sizeof(str), format, va);
+
+ function(str, user_data);
+}
+
void util_debug(util_debug_func_t function, void *user_data,
const char *format, ...)
{
- char str[78];
va_list ap;
if (!function || !format)
return;
va_start(ap, format);
- vsnprintf(str, sizeof(str), format, ap);
+ util_debug_va(function, user_data, format, ap);
va_end(ap);
-
- function(str, user_data);
}
void util_hexdump(const char dir, const unsigned char *buf, size_t len,
@@ -10,6 +10,7 @@
#include <stdint.h>
#include <stdlib.h>
+#include <stdarg.h>
#include <alloca.h>
#include <byteswap.h>
#include <string.h>
@@ -89,6 +90,9 @@ void *btd_malloc(size_t size);
typedef void (*util_debug_func_t)(const char *str, void *user_data);
+void util_debug_va(util_debug_func_t function, void *user_data,
+ const char *format, va_list va);
+
void util_debug(util_debug_func_t function, void *user_data,
const char *format, ...)
__attribute__((format(printf, 3, 4)));
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> This introduces util_debug_va which can take a va_list that enables callers to create wrapper functions if they need to. --- src/shared/util.c | 19 ++++++++++++++----- src/shared/util.h | 4 ++++ 2 files changed, 18 insertions(+), 5 deletions(-)