X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/ed4a59a248d0efa948a8a3ea499d55bc96025234..c6189d1b7b02cda083791afc98f7e632100424d5:/src/xbt/mmalloc/mm_legacy.c diff --git a/src/xbt/mmalloc/mm_legacy.c b/src/xbt/mmalloc/mm_legacy.c index e88538ab89..96610ee1ca 100644 --- a/src/xbt/mmalloc/mm_legacy.c +++ b/src/xbt/mmalloc/mm_legacy.c @@ -30,7 +30,7 @@ void mmalloc_set_current_heap(xbt_mheap_t new_heap) __mmalloc_current_heap = new_heap; } -#ifdef MMALLOC_WANT_OVERIDE_LEGACY +#ifdef MMALLOC_WANT_OVERRIDE_LEGACY void *malloc(size_t n) { xbt_mheap_t mdp = __mmalloc_current_heap ?: (xbt_mheap_t) mmalloc_preinit(); @@ -69,11 +69,13 @@ void *realloc(void *p, size_t s) void free(void *p) { - xbt_mheap_t mdp = __mmalloc_current_heap ?: (xbt_mheap_t) mmalloc_preinit(); + if (p != NULL) { + xbt_mheap_t mdp = __mmalloc_current_heap ?: (xbt_mheap_t) mmalloc_preinit(); - LOCK(mdp); - mfree(mdp, p); - UNLOCK(mdp); + LOCK(mdp); + mfree(mdp, p); + UNLOCK(mdp); + } } #endif