From 932b32f3ce5bb1d33aff7fa54faf1229ee68eb6d Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Thu, 2 Feb 2012 21:14:25 +0100 Subject: [PATCH 1/1] there were no difference between __mmalloc_free and mfree anymore; merge them --- src/xbt/mmalloc/mfree.c | 14 +++++--------- src/xbt/mmalloc/mmalloc.c | 2 +- src/xbt/mmalloc/mmprivate.h | 6 +----- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/xbt/mmalloc/mfree.c b/src/xbt/mmalloc/mfree.c index 41eefb106d..bb7bd00a68 100644 --- a/src/xbt/mmalloc/mfree.c +++ b/src/xbt/mmalloc/mfree.c @@ -15,7 +15,8 @@ /* Return memory to the heap. Like `mfree' but don't call a mfree_hook if there is one. */ -void __mmalloc_free(struct mdesc *mdp, void *ptr) +/* Return memory to the heap. */ +void mfree(struct mdesc *mdp, void *ptr) { int type; size_t block; @@ -23,6 +24,9 @@ void __mmalloc_free(struct mdesc *mdp, void *ptr) struct list *prev, *next; int it; + if (ptr == NULL) + return; + block = BLOCK(ptr); if ((char *) ptr < (char *) mdp->heapbase || block > mdp->heapsize) { @@ -163,11 +167,3 @@ void __mmalloc_free(struct mdesc *mdp, void *ptr) break; } } - -/* Return memory to the heap. */ - -void mfree(xbt_mheap_t mdp, void *ptr) -{ - if (ptr != NULL) - __mmalloc_free(mdp, ptr); -} diff --git a/src/xbt/mmalloc/mmalloc.c b/src/xbt/mmalloc/mmalloc.c index 29451d1587..3e9bdf2034 100644 --- a/src/xbt/mmalloc/mmalloc.c +++ b/src/xbt/mmalloc/mmalloc.c @@ -96,7 +96,7 @@ static void *register_morecore(struct mdesc *mdp, size_t size) newinfo[BLOCK(oldinfo)].type = 0; newinfo[BLOCK(oldinfo)].busy_block.size = BLOCKIFY(mdp->heapsize * sizeof(malloc_info)); newinfo[BLOCK(oldinfo)].busy_block.busy_size = size; - __mmalloc_free(mdp, (void *) oldinfo); + mfree(mdp, (void *) oldinfo); mdp->heapsize = newsize; } diff --git a/src/xbt/mmalloc/mmprivate.h b/src/xbt/mmalloc/mmprivate.h index b87c21d8b2..8352e13379 100644 --- a/src/xbt/mmalloc/mmprivate.h +++ b/src/xbt/mmalloc/mmprivate.h @@ -183,7 +183,7 @@ struct mdesc { size_t heaplimit; /* Block information table. - Allocated with malign/__mmalloc_free (not mmalloc/mfree). */ + Allocated with malign/mfree (not mmalloc/mfree). */ /* Table indexed by block number giving per-block information. */ malloc_info *heapinfo; @@ -225,10 +225,6 @@ void mmalloc_display_info(void *h); #define MMALLOC_ANONYMOUS (1 << 1) /* Use anonymous mapping */ #define MMALLOC_INITIALIZED (1 << 2) /* Initialized mmalloc */ -/* Internal version of `mfree' used in `morecore'. */ - -extern void __mmalloc_free(struct mdesc *mdp, void *ptr); - /* A default malloc descriptor for the single sbrk() managed region. */ extern struct mdesc *__mmalloc_default_mdp; -- 2.20.1