Skip to content

Commit 00b0d7f

Browse files
committed
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>
1 parent 6068ac8 commit 00b0d7f

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

trace.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@
2525
#include "cache.h"
2626
#include "quote.h"
2727

28-
static void do_nothing(size_t unused)
29-
{
30-
}
31-
3228
/* Get a trace file descriptor from GIT_TRACE env variable. */
3329
static int get_trace_fd(int *need_close)
3430
{
@@ -76,7 +72,7 @@ void trace_printf(const char *fmt, ...)
7672
if (!fd)
7773
return;
7874

79-
set_try_to_free_routine(do_nothing); /* is never reset */
75+
set_try_to_free_routine(NULL); /* is never reset */
8076
strbuf_init(&buf, 64);
8177
va_start(ap, fmt);
8278
len = vsnprintf(buf.buf, strbuf_avail(&buf), fmt, ap);
@@ -108,7 +104,7 @@ void trace_argv_printf(const char **argv, const char *fmt, ...)
108104
if (!fd)
109105
return;
110106

111-
set_try_to_free_routine(do_nothing); /* is never reset */
107+
set_try_to_free_routine(NULL); /* is never reset */
112108
strbuf_init(&buf, 64);
113109
va_start(ap, fmt);
114110
len = vsnprintf(buf.buf, strbuf_avail(&buf), fmt, ap);

wrapper.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ static void (*try_to_free_routine)(size_t size) = do_nothing;
1212
try_to_free_t set_try_to_free_routine(try_to_free_t routine)
1313
{
1414
try_to_free_t old = try_to_free_routine;
15+
if (!routine)
16+
routine = do_nothing;
1517
try_to_free_routine = routine;
1618
return old;
1719
}

0 commit comments

Comments
 (0)