X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/bce048d821047a65f5044bb332515bba8ea90927..406f54970c00ca178fa918763d943027bd09e3ba:/src/xbt/mmalloc/mm_legacy.c diff --git a/src/xbt/mmalloc/mm_legacy.c b/src/xbt/mmalloc/mm_legacy.c index 86ee95cdff..9ae3771bef 100644 --- a/src/xbt/mmalloc/mm_legacy.c +++ b/src/xbt/mmalloc/mm_legacy.c @@ -7,11 +7,9 @@ /* Redefine the classical malloc/free/realloc functions so that they fit well in the mmalloc framework */ #include "mmprivate.h" -#include "gras_config.h" +#include "internal_config.h" #include -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_mm_legacy, xbt, - "Logging specific to mm_legacy in mmalloc"); /* The mmalloc() package can use a single implicit malloc descriptor for mmalloc/mrealloc/mfree operations which do not supply an explicit @@ -32,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(); @@ -71,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