@matheusbsbs / matheus-bagliano / commits / 00b0d7f77b
Fork 0

set_try_to_free_routine(NULL) means "do nothing special"

This way, the next caller that wants to disable our memory reclamation machinery does not have to define its own do_nothing() stub. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Dec 21, 2010 at 09:24 UTC 00b0d7f77b65ed2d059f893bbd2011ba5bb4252d
2 files changed +4 -6
trace.c
+2 -6
@@ -25,10 +25,6 @@
25 #include "cache.h"
26 #include "quote.h"
27
28 -static void do_nothing(size_t unused)
29 -{
30 -}
31 -
28 /* Get a trace file descriptor from GIT_TRACE env variable. */
29 static int get_trace_fd(int *need_close)
30 {
@@ -76,7 +72,7 @@ void trace_printf(const char *fmt, ...)
72 if (!fd)
73 return;
74
79 - set_try_to_free_routine(do_nothing); /* is never reset */
75 + set_try_to_free_routine(NULL); /* is never reset */
76 strbuf_init(&buf, 64);
77 va_start(ap, fmt);
78 len = vsnprintf(buf.buf, strbuf_avail(&buf), fmt, ap);
@@ -108,7 +104,7 @@ void trace_argv_printf(const char **argv, const char *fmt, ...)
104 if (!fd)
105 return;
106
111 - set_try_to_free_routine(do_nothing); /* is never reset */
107 + set_try_to_free_routine(NULL); /* is never reset */
108 strbuf_init(&buf, 64);
109 va_start(ap, fmt);
110 len = vsnprintf(buf.buf, strbuf_avail(&buf), fmt, ap);
wrapper.c
+2
@@ -12,6 +12,8 @@ static void (*try_to_free_routine)(size_t size) = do_nothing;
12 try_to_free_t set_try_to_free_routine(try_to_free_t routine)
13 {
14 try_to_free_t old = try_to_free_routine;
15 + if (!routine)
16 + routine = do_nothing;
17 try_to_free_routine = routine;
18 return old;
19 }