From a9a746364bd26d333c7229c6f7e851b507cd284a Mon Sep 17 00:00:00 2001 From: Nicolas Pitre Date: Wed, 24 Mar 2010 16:22:34 -0400 Subject: Make xmalloc and xrealloc thread-safe By providing a hook for the routine responsible for trying to free some memory on malloc failure, we can ensure that the called routine is protected by the appropriate locks when threads are in play. The obvious offender here was pack-objects which was calling xmalloc() within threads while release_pack_memory() is not thread safe. Signed-off-by: Nicolas Pitre Signed-off-by: Junio C Hamano --- git-compat-util.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'git-compat-util.h') diff --git a/git-compat-util.h b/git-compat-util.h index a3c4537366..1c171db8b1 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -346,6 +346,8 @@ static inline char *gitstrchrnul(const char *s, int c) extern void release_pack_memory(size_t, int); +extern void set_try_to_free_routine(void (*routine)(size_t)); + extern char *xstrdup(const char *str); extern void *xmalloc(size_t size); extern void *xmallocz(size_t size); -- cgit v1.2.3