summaryrefslogtreecommitdiff
path: root/git-compat-util.h
diff options
context:
space:
mode:
authorNicolas Pitre <nico@fluxnic.net>2010-03-24 20:22:34 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-03-24 21:15:09 (GMT)
commita9a746364bd26d333c7229c6f7e851b507cd284a (patch)
tree72116fd86230efbfdd21f0fa78e68cb8a88a2a2d /git-compat-util.h
parent846b8f681a0a75cec2b930007c84e98346940459 (diff)
downloadgit-a9a746364bd26d333c7229c6f7e851b507cd284a.zip
git-a9a746364bd26d333c7229c6f7e851b507cd284a.tar.gz
git-a9a746364bd26d333c7229c6f7e851b507cd284a.tar.bz2
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 <nico@fluxnic.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-compat-util.h')
-rw-r--r--git-compat-util.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/git-compat-util.h b/git-compat-util.h
index a3c4537..1c171db 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);