Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
set size to -1 for free fragments in new fragmented block
authorMarion Guthmuller <marion.guthmuller@loria.fr>
Tue, 9 Oct 2012 01:54:29 +0000 (03:54 +0200)
committerMarion Guthmuller <marion.guthmuller@loria.fr>
Tue, 9 Oct 2012 01:54:29 +0000 (03:54 +0200)
src/xbt/mmalloc/mfree.c
src/xbt/mmalloc/mmalloc.c

index cbdea22..e8242f6 100644 (file)
@@ -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 ==
index 7584c63..c54fb4c 100644 (file)
@@ -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];