Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Sonar still does not like #undef. Use a local variable to hide _xbt_log_cat_init.
[simgrid.git] / src / xbt / mmalloc / mrealloc.c
index 589e412..aabf868 100644 (file)
@@ -22,7 +22,6 @@ void *mrealloc(xbt_mheap_t mdp, void *ptr, size_t size)
 {
   void *result;
   size_t blocks;
-  size_t oldlimit;
 
   /* Only keep real realloc, and reroute hidden malloc and free to the relevant functions */
   if (size == 0) {
@@ -37,9 +36,7 @@ void *mrealloc(xbt_mheap_t mdp, void *ptr, size_t 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");
-    result = mmalloc(mdp, size);
     abort();
-    return result;
   }
 
   size_t requested_size = size; // The amount of memory requested by user, for real
@@ -92,8 +89,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;
@@ -115,7 +111,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;