summaryrefslogtreecommitdiff
path: root/trace.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2011-02-24 09:28:15 -0500
committerJunio C Hamano <gitster@pobox.com>2011-03-08 12:12:04 -0800
commitc6053543f288f503b39e946ef58bfcd59f935b5f (patch)
treed7d25b5e825352e335f5a11a96be10ed9829411e /trace.c
parent26db0f2e3afc043e184a5e0ce5eb7c53aeb1f644 (diff)
downloadgit-c6053543f288f503b39e946ef58bfcd59f935b5f.tar.gz
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>
Diffstat (limited to 'trace.c')
-rw-r--r--trace.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/trace.c b/trace.c
index eda3f6d721..623e793e4f 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_vaddf(&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;