[PATCH 3/8] trace: add trace_vprintf
From: Jeff King <hidden>
Date: 2016-06-15 22:50:39
Subsystem:
the rest · Maintainer:
Linus Torvalds
This is a necessary cleanup to adding new types of trace functions. Signed-off-by: Jeff King <redacted> --- cache.h | 1 + trace.c | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/cache.h b/cache.h
index 4a758ba..08b23b2 100644
--- a/cache.h
+++ b/cache.h@@ -1067,6 +1067,7 @@ extern void alloc_report(void); /* trace.c */ __attribute__((format (printf, 1, 2))) extern void trace_printf(const char *format, ...); +extern void trace_vprintf(const char *format, va_list ap); __attribute__((format (printf, 2, 3))) extern void trace_argv_printf(const char **argv, const char *format, ...); extern void trace_repo_setup(const char *prefix);
diff --git a/trace.c b/trace.c
index 745543c..6ad7788 100644
--- a/trace.c
+++ b/trace.c@@ -62,10 +62,9 @@ static int get_trace_fd(int *need_close) static const char err_msg[] = "Could not trace into fd given by " "GIT_TRACE environment variable"; -void trace_printf(const char *fmt, ...) +void trace_vprintf(const char *fmt, va_list ap) { struct strbuf buf = STRBUF_INIT; - va_list ap; int fd, need_close = 0; fd = get_trace_fd(&need_close);
@@ -73,10 +72,7 @@ void trace_printf(const char *fmt, ...) return; set_try_to_free_routine(NULL); /* is never reset */ - va_start(ap, fmt); strbuf_addv(&buf, fmt, ap); - va_end(ap); - write_or_whine_pipe(fd, buf.buf, buf.len, err_msg); strbuf_release(&buf);
@@ -84,6 +80,14 @@ void trace_printf(const char *fmt, ...) close(fd); } +void trace_printf(const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + trace_vprintf(fmt, ap); + va_end(ap); +} + void trace_argv_printf(const char **argv, const char *fmt, ...) { struct strbuf buf = STRBUF_INIT;
--
1.7.2.5.25.g3bb93