Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
model-checker : initialize pointer and update indice of search in heapinfo
[simgrid.git] / src / xbt / mmalloc / mm_diff.c
index 17dca5f..14adfa2 100644 (file)
@@ -204,7 +204,7 @@ int mmalloc_compare_mdesc(struct mdesc *mdp1, struct mdesc *mdp2, void* s_heap,
   int distance = 0;
   int pointer_align;
 
-  char *pointed_address1, *pointed_address2;
+  char *pointed_address1 = NULL, *pointed_address2 = NULL;
 
   /* Check busy blocks*/
 
@@ -215,8 +215,8 @@ int mmalloc_compare_mdesc(struct mdesc *mdp1, struct mdesc *mdp2, void* s_heap,
       errors++;
     }
 
-    addr_block1 = (char *)mdp1 + sizeof(struct mdesc) + (i * BLOCKSIZE);
-    addr_block2 = (char *)mdp2 + sizeof(struct mdesc) + (i * BLOCKSIZE);
+    addr_block1 = (char *)mdp1 + mdp1->headersize + ((i-1) * BLOCKSIZE);
+    addr_block2 = (char *)mdp2 + mdp2->headersize + ((i-1) * BLOCKSIZE); 
 
     if(mdp1->heapinfo[i].type == 0){ /* busy large block */
 
@@ -247,7 +247,7 @@ int mmalloc_compare_mdesc(struct mdesc *mdp1, struct mdesc *mdp2, void* s_heap,
            fprintf(stderr, "Pointed address : %p (in %s) - %p (in %s)\n", *((void **)((char *)addr_block1 + pointer_align)), pointed_address1, *((void **)((char *)addr_block2 + pointer_align)), pointed_address2);
            if((strcmp(pointed_address1, pointed_address2) == 0) && (strcmp(pointed_address1, "std_heap") == 0)){
              /* FIXME : compare value pointed thanks to DWARF */
-           } 
+           }
          }
        }
 
@@ -258,7 +258,10 @@ int mmalloc_compare_mdesc(struct mdesc *mdp1, struct mdesc *mdp2, void* s_heap,
        errors++;
       }
 
-      i = i + mdp1->heapinfo[i].busy_block.size + 1;
+      if( mdp1->heapinfo[i].busy_block.size == 0)
+       i = i + 1;
+      else
+       i = i + mdp1->heapinfo[i].busy_block.size;
 
     }else{
       
@@ -336,6 +339,8 @@ int mmalloc_compare_mdesc(struct mdesc *mdp1, struct mdesc *mdp2, void* s_heap,
 
   }
 
+  free(pointed_address1);
+  free(pointed_address2);
 
   return (errors);
 }
@@ -354,6 +359,7 @@ const char* get_addr_memory_map(void *addr, void* s_heap, void* r_heap){
     perror("fopen failed");
 
   if(addr == NULL){
+    free(line);
     fclose(fp);
     return "nil";
   }