diff options
Diffstat (limited to 'src/malloc/malloc.c')
-rw-r--r-- | src/malloc/malloc.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/malloc/malloc.c b/src/malloc/malloc.c index 239ab9c6..d72883e1 100644 --- a/src/malloc/malloc.c +++ b/src/malloc/malloc.c @@ -20,6 +20,8 @@ static struct { volatile int free_lock[2]; } mal; +int __malloc_replaced; + /* Synchronization tools */ static inline void lock(volatile int *lk) @@ -356,10 +358,13 @@ void *calloc(size_t m, size_t n) } n *= m; void *p = malloc(n); - if (!p || IS_MMAPPED(MEM_TO_CHUNK(p))) - return p; - if (n >= PAGE_SIZE) - n = mal0_clear(p, PAGE_SIZE, n); + if (!p) return p; + if (!__malloc_replaced) { + if (IS_MMAPPED(MEM_TO_CHUNK(p))) + return p; + if (n >= PAGE_SIZE) + n = mal0_clear(p, PAGE_SIZE, n); + } return memset(p, 0, n); } |