@matheusbsbs / matheus-bagliano / commits / c6053543f2
Fork 0

trace: add trace_vprintf

This is a necessary cleanup to adding new types of trace functions. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Feb 24, 2011 at 09:28 UTC c6053543f288f503b39e946ef58bfcd59f935b5f
2 files changed +10 -5
cache.h
+1
@@ -1067,6 +1067,7 @@ extern void alloc_report(void);
1067 /* trace.c */
1068 __attribute__((format (printf, 1, 2)))
1069 extern void trace_printf(const char *format, ...);
1070 +extern void trace_vprintf(const char *format, va_list ap);
1071 __attribute__((format (printf, 2, 3)))
1072 extern void trace_argv_printf(const char **argv, const char *format, ...);
1073 extern void trace_repo_setup(const char *prefix);
trace.c
+9 -5
@@ -62,10 +62,9 @@ static int get_trace_fd(int *need_close)
62 static const char err_msg[] = "Could not trace into fd given by "
63 "GIT_TRACE environment variable";
64
65 -void trace_printf(const char *fmt, ...)
65 +void trace_vprintf(const char *fmt, va_list ap)
66 {
67 struct strbuf buf = STRBUF_INIT;
68 - va_list ap;
68 int fd, need_close = 0;
69
70 fd = get_trace_fd(&need_close);
@@ -73,10 +72,7 @@ void trace_printf(const char *fmt, ...)
72 return;
73
74 set_try_to_free_routine(NULL); /* is never reset */
76 - va_start(ap, fmt);
75 strbuf_vaddf(&buf, fmt, ap);
78 - va_end(ap);
79 -
76 write_or_whine_pipe(fd, buf.buf, buf.len, err_msg);
77 strbuf_release(&buf);
78
@@ -84,6 +80,14 @@ void trace_printf(const char *fmt, ...)
80 close(fd);
81 }
82
83 +void trace_printf(const char *fmt, ...)
84 +{
85 + va_list ap;
86 + va_start(ap, fmt);
87 + trace_vprintf(fmt, ap);
88 + va_end(ap);
89 +}
90 +
91 void trace_argv_printf(const char **argv, const char *fmt, ...)
92 {
93 struct strbuf buf = STRBUF_INIT;