From a98abccf998144ff81e429cdb16af5b93fe7973b Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Wed, 4 Nov 2009 14:00:03 -0500 Subject: Simplify debug_fn() We don't need to be allocating an output string here. This was also causing a runtime bug when the output string contained characters that would be interpreted by fprintf as specifiers. --- server/util/debug.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'server') diff --git a/server/util/debug.c b/server/util/debug.c index 862367ce5..df2ba6931 100644 --- a/server/util/debug.c +++ b/server/util/debug.c @@ -56,23 +56,13 @@ errno_t set_debug_file_from_fd(const int fd) void debug_fn(const char *format, ...) { va_list ap; - char *s = NULL; - int ret; va_start(ap, format); - ret = vasprintf(&s, format, ap); - if (ret < 0) { - /* ENOMEM */ - return; - } + vfprintf(debug_file ? debug_file : stderr, format, ap); + fflush(debug_file ? debug_file : stderr); va_end(ap); - - /*write(state.fd, s, strlen(s));*/ - fprintf(debug_file ? debug_file : stderr, s); - fflush(debug_file ? debug_file : stderr); - free(s); } void ldb_debug_messages(void *context, enum ldb_debug_level level, -- cgit