mdp->heapsize * sizeof(malloc_info));
oldinfo = mdp->heapinfo;
newinfo[BLOCK(oldinfo)].busy.type = 0;
- newinfo[BLOCK(oldinfo)].busy.info.size
+ newinfo[BLOCK(oldinfo)].busy.info.block.size
= BLOCKIFY(mdp->heapsize * sizeof(malloc_info));
+ newinfo[BLOCK(oldinfo)].busy.info.block.busy_size = size;
mdp->heapinfo = newinfo;
__mmalloc_free(mdp, (void *) oldinfo);
mdp->heapsize = newsize;
size = 1;
mdp = MD_TO_MDP(md);
- LOCK(mdp);
// printf("(%s) Mallocing %d bytes on %p (default: %p)...",xbt_thread_self_name(),size,mdp,__mmalloc_default_mdp);fflush(stdout);
-
if (mdp->mmalloc_hook != NULL) {
- void *res = ((*mdp->mmalloc_hook) (md, size));
- UNLOCK(mdp);
- return res;
+ return mdp->mmalloc_hook(md, size);
}
if (!(mdp->flags & MMALLOC_INITIALIZED)) {
if (!initialize(mdp)) {
- UNLOCK(mdp);
return (NULL);
}
}
} else {
/* No free fragments of the desired size, so get a new block
and break it into fragments, returning the first. */
- UNLOCK(mdp);
//printf("(%s) No free fragment...",xbt_thread_self_name());
result = mmalloc(md, BLOCKSIZE);
//printf("(%s) Fragment: %p...",xbt_thread_self_name(),result);
- LOCK(mdp);
if (result == NULL) {
- UNLOCK(mdp);
return (NULL);
}
}
result = morecore(mdp, blocks * BLOCKSIZE);
if (result == NULL) {
- UNLOCK(mdp);
return (NULL);
}
block = BLOCK(result);
mdp->heapinfo[block].busy.type = 0;
- mdp->heapinfo[block].busy.info.size = blocks;
+ mdp->heapinfo[block].busy.info.block.size = blocks;
+ mdp->heapinfo[block].busy.info.block.busy_size = size;
mdp->heapstats.chunks_used++;
mdp->heapstats.bytes_used += blocks * BLOCKSIZE;
- UNLOCK(mdp);
return (result);
}
}
}
mdp->heapinfo[block].busy.type = 0;
- mdp->heapinfo[block].busy.info.size = blocks;
+ mdp->heapinfo[block].busy.info.block.size = blocks;
+ mdp->heapinfo[block].busy.info.block.busy_size = size;
mdp->heapstats.chunks_used++;
mdp->heapstats.bytes_used += blocks * BLOCKSIZE;
mdp->heapstats.bytes_free -= blocks * BLOCKSIZE;
}
//printf("(%s) Done mallocing. Result is %p\n",xbt_thread_self_name(),result);fflush(stdout);
- UNLOCK(mdp);
return (result);
}