size_t requested_size = size; // The amount of memory requested by user, for real
+ check_fraghead(mdp);
+
/* Work even if the user was stupid enough to ask a ridicullously small block (even 0-length),
* ie return a valid block that can be realloced and freed.
* glibc malloc does not use this trick but return a constant pointer, but we need to enlist the free fragments later on.
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];
mdp->heapinfo[block].busy_block.bt_size=xbt_backtrace_no_malloc(mdp->heapinfo[block].busy_block.bt,XBT_BACKTRACE_SIZE);
mdp -> heapstats.chunks_used++;
mdp -> heapstats.bytes_used += blocks * BLOCKSIZE;
+
+ check_fraghead(mdp);
+
return result;
}
/* Need large block(s), but found some in the existing heap */
}
//printf("(%s) Done mallocing. Result is %p\n",xbt_thread_self_name(),result);fflush(stdout);
+ check_fraghead(mdp);
return (result);
}