From 27eac930728f84bf31b65013f7d95e39b3ea0063 Mon Sep 17 00:00:00 2001 From: Marion Guthmuller Date: Tue, 9 Oct 2012 03:54:29 +0200 Subject: [PATCH] set size to -1 for free fragments in new fragmented block --- src/xbt/mmalloc/mfree.c | 2 +- src/xbt/mmalloc/mmalloc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/xbt/mmalloc/mfree.c b/src/xbt/mmalloc/mfree.c index cbdea22070..e8242f67c8 100644 --- a/src/xbt/mmalloc/mfree.c +++ b/src/xbt/mmalloc/mfree.c @@ -150,7 +150,6 @@ void mfree(struct mdesc *mdp, void *ptr) ((char *) ADDRESS(block) + (mdp->heapinfo[block].busy_frag.first << type)); - /* Set size used in the fragment to 0 */ frag_nb = RESIDUAL(ptr, BLOCKSIZE) >> type; if( mdp->heapinfo[block].busy_frag.frag_size[frag_nb] == -1){ @@ -158,6 +157,7 @@ void mfree(struct mdesc *mdp, void *ptr) THROWF(system_error, 0, "Asked to free a fragment that is already free. I'm puzzled\n"); } + /* Set size used in the fragment to -1 */ mdp->heapinfo[block].busy_frag.frag_size[frag_nb] = -1; if (mdp->heapinfo[block].busy_frag.nfree == diff --git a/src/xbt/mmalloc/mmalloc.c b/src/xbt/mmalloc/mmalloc.c index 7584c63335..c54fb4c52e 100644 --- a/src/xbt/mmalloc/mmalloc.c +++ b/src/xbt/mmalloc/mmalloc.c @@ -184,10 +184,10 @@ void *mmalloc_no_memset(xbt_mheap_t mdp, size_t size) result = mmalloc(mdp, BLOCKSIZE); // does not return NULL - /* Link all fragments but the first into the free list, and mark their requested size to 0. */ + /* Link all fragments but the first into the free list, and mark their requested size to -1. */ block = BLOCK(result); for (i = 1; i < (size_t) (BLOCKSIZE >> log); ++i) { - mdp->heapinfo[block].busy_frag.frag_size[i] = 0; + mdp->heapinfo[block].busy_frag.frag_size[i] = -1; next = (struct list *) ((char *) result + (i << log)); next->next = mdp->fraghead[log].next; next->prev = &mdp->fraghead[log]; -- 2.20.1