- mdp->heapstats.chunks_free += (BLOCKSIZE >> log) - 1;
- mdp->heapstats.bytes_free += BLOCKSIZE - (1 << log);
- mdp->heapstats.bytes_used -= BLOCKSIZE - (1 << log);
+ mdp->heapinfo[block].type = log;
+ /* Link all fragments but the first as free, and add the block to the swag of blocks containing free frags */
+ for (i = 1; i < (size_t) (BLOCKSIZE >> log); ++i) {
+ mdp->heapinfo[block].busy_frag.frag_size[i] = -1;
+ mdp->heapinfo[block].busy_frag.ignore[i] = 0;
+ mdp->heapinfo[block].busy_frag.equal_to[i] = NULL;
+ }
+ mdp->heapinfo[block].busy_frag.nfree = i - 1;
+ mdp->heapinfo[block].freehook.prev = NULL;
+ mdp->heapinfo[block].freehook.next = NULL;
+
+ xbt_swag_insert(&mdp->heapinfo[block], &(mdp->fraghead[log]));
+
+ /* mark the fragment returned as busy */
+ mdp->heapinfo[block].busy_frag.frag_size[0] = requested_size;
+ mdp->heapinfo[block].busy_frag.ignore[0] = 0;
+ mdp->heapinfo[block].busy_frag.equal_to[0] = NULL;
+ //xbt_backtrace_no_malloc(mdp->heapinfo[block].busy_frag.bt[0],XBT_BACKTRACE_SIZE);
+ //xbt_libunwind_backtrace(mdp->heapinfo[block].busy_frag.bt[0],XBT_BACKTRACE_SIZE);
+
+ /* update stats */
+ mdp -> heapstats.chunks_free += (BLOCKSIZE >> log) - 1;
+ mdp -> heapstats.bytes_free += BLOCKSIZE - (1 << log);
+ mdp -> heapstats.bytes_used -= BLOCKSIZE - (1 << log);