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>
This commit is contained in:

committed by
Junio C Hamano

parent
846b8f681a
commit
a9a746364b
@ -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);
|
||||
|
Reference in New Issue
Block a user