X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=wrapper.c;h=fd8ead33ed72c37e690ee1fc5b8568f629c95145;hb=2844923d62a4c408bd59ddb2caacca4aa7eb86bc;hp=58201b6bcb8d362cffd1222bcb8cd77072c34cf5;hpb=c4818faf81d32d940c58ab209f83b6049b33ecbb;p=git.git diff --git a/wrapper.c b/wrapper.c index 58201b6bc..fd8ead33e 100644 --- a/wrapper.c +++ b/wrapper.c @@ -10,9 +10,11 @@ static void try_to_free_builtin(size_t size) static void (*try_to_free_routine)(size_t size) = try_to_free_builtin; -void set_try_to_free_routine(void (*routine)(size_t)) +try_to_free_t set_try_to_free_routine(try_to_free_t routine) { - try_to_free_routine = (routine) ? routine : try_to_free_builtin; + try_to_free_t old = try_to_free_routine; + try_to_free_routine = routine; + return old; } char *xstrdup(const char *str) @@ -38,7 +40,8 @@ void *xmalloc(size_t size) if (!ret && !size) ret = malloc(1); if (!ret) - die("Out of memory, malloc failed"); + die("Out of memory, malloc failed (tried to allocate %lu bytes)", + (unsigned long)size); } #ifdef XMALLOC_POISON memset(ret, 0xA5, size);