/* Get as many statistics as early as we can. */
mdp->heapstats.chunks_used--;
mdp->heapstats.bytes_used -=
- mdp->heapinfo[block].busy.info.size * BLOCKSIZE;
+ mdp->heapinfo[block].busy.info.block.size * BLOCKSIZE;
mdp->heapstats.bytes_free +=
- mdp->heapinfo[block].busy.info.size * BLOCKSIZE;
+ mdp->heapinfo[block].busy.info.block.size * BLOCKSIZE;
/* Find the free cluster previous to this one in the free list.
Start searching at the last block referenced; this may benefit
/* Determine how to link this block into the free list. */
if (block == i + mdp->heapinfo[i].free.size) {
/* Coalesce this block with its predecessor. */
- mdp->heapinfo[i].free.size += mdp->heapinfo[block].busy.info.size;
+ mdp->heapinfo[i].free.size += mdp->heapinfo[block].busy.info.block.size;
block = i;
} else {
/* Really link this block back into the free list. */
- mdp->heapinfo[block].free.size = mdp->heapinfo[block].busy.info.size;
+ mdp->heapinfo[block].free.size = mdp->heapinfo[block].busy.info.block.size;
mdp->heapinfo[block].free.next = mdp->heapinfo[i].free.next;
mdp->heapinfo[block].free.prev = i;
mdp->heapinfo[i].free.next = block;
next->prev = prev->prev;
}
mdp->heapinfo[block].busy.type = 0;
- mdp->heapinfo[block].busy.info.size = 1;
+ mdp->heapinfo[block].busy.info.block.size = 1;
+ mdp->heapinfo[block].busy.info.block.busy_size = 0;
/* Keep the statistics accurate. */
mdp->heapstats.chunks_used++;
switch(mdp1->heapinfo[i].busy.type){
case 0 :
- if(mdp1->heapinfo[i].busy.info.size != mdp2->heapinfo[i].busy.info.size){
+ if(mdp1->heapinfo[i].busy.info.block.size != mdp2->heapinfo[i].busy.info.block.size){
if(XBT_LOG_ISENABLED(xbt_mm_legacy, xbt_log_priority_debug)){
XBT_DEBUG("Different size of a large cluster");
errors++;
return 1;
}
}else{
- if(memcmp(addr_block1, addr_block2, (mdp1->heapinfo[i].busy.info.size * BLOCKSIZE)) != 0){
+ if(memcmp(addr_block1, addr_block2, (mdp1->heapinfo[i].busy.info.block.size * BLOCKSIZE)) != 0){
if(XBT_LOG_ISENABLED(xbt_mm_legacy, xbt_log_priority_debug)){
- XBT_DEBUG("Different data in block %zu (size = %zu) (addr_block1 = %p (current = %p) - addr_block2 = %p)", i, mdp1->heapinfo[i].busy.info.size, addr_block1, (char *)std_heap_addr + sizeof(struct mdesc) + ((i-1) * BLOCKSIZE), addr_block2);
+ XBT_DEBUG("Different data in block %zu (size = %zu) (addr_block1 = %p (current = %p) - addr_block2 = %p)", i, mdp1->heapinfo[i].busy.info.block.size, addr_block1, (char *)std_heap_addr + sizeof(struct mdesc) + ((i-1) * BLOCKSIZE), addr_block2);
errors++;
}else{
return 1;
}
}
}
- i = i+mdp1->heapinfo[i].busy.info.size;
+ i = i+mdp1->heapinfo[i].busy.info.block.size;
break;
default :
switch(mdp1->heapinfo[i].busy.type){
case 0 :
- if(mdp1->heapinfo[i].busy.info.size != mdp2->heapinfo[i].busy.info.size){
+ if(mdp1->heapinfo[i].busy.info.block.size != mdp2->heapinfo[i].busy.info.block.size){
if(XBT_LOG_ISENABLED(xbt_mm_legacy, xbt_log_priority_debug)){
XBT_DEBUG("Different size of a large cluster");
errors++;
return 1;
}
}else{
- if(memcmp(addr_block1, addr_block2, (mdp1->heapinfo[i].busy.info.size * BLOCKSIZE)) != 0){
+ if(memcmp(addr_block1, addr_block2, (mdp1->heapinfo[i].busy.info.block.size * BLOCKSIZE)) != 0){
if(XBT_LOG_ISENABLED(xbt_mm_legacy, xbt_log_priority_debug)){
XBT_DEBUG("Different data in block %zu (addr_block1 = %p (current = %p) - addr_block2 = %p)", i, addr_block1, (char *)std_heap_addr + sizeof(struct mdesc) + ((i-1) * BLOCKSIZE), addr_block2);
errors++;
}
}
- i = i+mdp1->heapinfo[i].busy.info.size;
+ i = i+mdp1->heapinfo[i].busy.info.block.size;
break;
default :
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;
}
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;
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;
size_t nfree; /* Free fragments in a fragmented block. */
size_t first; /* First free fragment of the block. */
} frag;
- /* Size (in blocks) of a large cluster. */
- size_t size;
+ struct {
+ size_t size; /* Size (in blocks) of a large cluster. */
+ size_t busy_size;
+ } block;
} info;
} busy;
/* Heap information for a free block (that may be the first of
/* The new size is a large allocation as well;
see if we can hold it in place. */
blocks = BLOCKIFY(size);
- if (blocks < mdp->heapinfo[block].busy.info.size) {
+ if (blocks < mdp->heapinfo[block].busy.info.block.size) {
/* The new size is smaller; return excess memory to the free list. */
//printf("(%s) return excess memory...",xbt_thread_self_name());
mdp->heapinfo[block + blocks].busy.type = 0;
- mdp->heapinfo[block + blocks].busy.info.size
- = mdp->heapinfo[block].busy.info.size - blocks;
- mdp->heapinfo[block].busy.info.size = blocks;
+ mdp->heapinfo[block + blocks].busy.info.block.size
+ = mdp->heapinfo[block].busy.info.block.size - blocks;
+ mdp->heapinfo[block].busy.info.block.size = blocks;
+ mdp->heapinfo[block].busy.info.block.busy_size = size;
mfree(md, ADDRESS(block + blocks));
result = ptr;
- } else if (blocks == mdp->heapinfo[block].busy.info.size) {
+ } else if (blocks == mdp->heapinfo[block].busy.info.block.size) {
/* No size change necessary. */
result = ptr;
} else {
/* Won't fit, so allocate a new region that will.
Free the old region first in case there is sufficient
adjacent free space to grow without moving. */
- blocks = mdp->heapinfo[block].busy.info.size;
+ blocks = mdp->heapinfo[block].busy.info.block.size;
/* Prevent free from actually returning memory to the system. */
oldlimit = mdp->heaplimit;
mdp->heaplimit = 0;