X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/a0fcde6efb589d65005c77e7d64b8634cbe277fc..b5858ae65676a0304a843e25d13d11df789106b6:/src/xbt/mmalloc/mrealloc.c diff --git a/src/xbt/mmalloc/mrealloc.c b/src/xbt/mmalloc/mrealloc.c index d0739609e1..dfd03b81b0 100644 --- a/src/xbt/mmalloc/mrealloc.c +++ b/src/xbt/mmalloc/mrealloc.c @@ -14,18 +14,14 @@ #include "mmprivate.h" -/* Resize the given region to the new size, returning a pointer - to the (possibly moved) region. This is optimized for speed; - some benchmarks seem to indicate that greater compactness is - achieved by unconditionally allocating and copying to a - new region. This module has incestuous knowledge of the - internals of both mfree and mmalloc. */ +/* Resize the given region to the new size, returning a pointer to the (possibly moved) region. This is optimized for + * speed; some benchmarks seem to indicate that greater compactness is achieved by unconditionally allocating and + * copying to a new region. This module has incestuous knowledge of the internals of both mfree and mmalloc. */ void *mrealloc(xbt_mheap_t mdp, void *ptr, size_t size) { void *result; - int type; - size_t block, blocks, oldlimit; + size_t blocks; /* Only keep real realloc, and reroute hidden malloc and free to the relevant functions */ if (size == 0) { @@ -38,8 +34,8 @@ void *mrealloc(xbt_mheap_t mdp, void *ptr, size_t size) //printf("(%s)realloc %p to %d...",xbt_thread_self_name(),ptr,(int)size); if ((char *) ptr < (char *) mdp->heapbase || BLOCK(ptr) > mdp->heapsize) { - printf - ("FIXME. Ouch, this pointer is not mine, refusing to proceed (another solution would be to malloc it instead of reallocing it, see source code)\n"); + printf("FIXME. Ouch, this pointer is not mine, refusing to proceed (another solution would be to malloc " + "it instead of reallocing it, see source code)\n"); result = mmalloc(mdp, size); abort(); return result; @@ -54,9 +50,9 @@ void *mrealloc(xbt_mheap_t mdp, void *ptr, size_t size) if (size < SMALLEST_POSSIBLE_MALLOC) size = SMALLEST_POSSIBLE_MALLOC; - block = BLOCK(ptr); + size_t block = BLOCK(ptr); - type = mdp->heapinfo[block].type; + int type = mdp->heapinfo[block].type; switch (type) { case MMALLOC_TYPE_HEAPINFO: @@ -95,8 +91,7 @@ void *mrealloc(xbt_mheap_t mdp, void *ptr, size_t size) mdp->heapinfo[it].busy_block.busy_size = 0; } - mdp->heapinfo[block + blocks].busy_block.size - = mdp->heapinfo[block].busy_block.size - blocks; + mdp->heapinfo[block + blocks].busy_block.size = mdp->heapinfo[block].busy_block.size - blocks; mfree(mdp, ADDRESS(block + blocks)); mdp->heapinfo[block].busy_block.size = blocks; @@ -118,7 +113,7 @@ void *mrealloc(xbt_mheap_t mdp, void *ptr, size_t size) action for obvious reasons. */ blocks = mdp->heapinfo[block].busy_block.size; /* Prevent free from actually returning memory to the system. */ - oldlimit = mdp->heaplimit; + size_t oldlimit = mdp->heaplimit; mdp->heaplimit = 0; mfree(mdp, ptr); mdp->heaplimit = oldlimit;