+ }
+
+ /* Check busy blocks*/
+
+ i1 = 1;
+
+ while(i1 <= heaplimit){
+
+ current_block = i1;
+
+ if(heapinfo1[i1].type == -1){ /* Free block */
+ i1++;
+ continue;
+ }
+
+ addr_block1 = ((void*) (((ADDR2UINT(i1)) - 1) * BLOCKSIZE + (char*)heapbase1));
+ real_addr_block1 = (char*)((xbt_mheap_t)s_heap)->heapbase + (((char *)addr_block1) - (char *)heapbase1);
+
+ if(heapinfo1[i1].type == 0){ /* Large block */
+
+ if((stack_name = is_stack(real_addr_block1)) != NULL){
+ stack_region_t stack = xbt_new0(s_stack_region_t, 1);
+ stack->address = addr_block1;
+ stack->process_name = strdup(stack_name);
+ stack->size = heapinfo1[i1].busy_block.busy_size;
+ xbt_dynar_push(*stack1, &stack);
+ }
+
+ if(heapinfo1[i1].busy_block.busy_size == 0){
+ i1++;
+ continue;
+ }
+
+ if(heapinfo1[i1].busy_block.equal_to != NULL){
+ i1++;
+ continue;
+ }
+
+ i2 = 1;
+ equal = 0;
+
+ /* Try first to associate to same block in the other heap */
+ if(heapinfo2[current_block].type == heapinfo1[current_block].type){
+
+ if(heapinfo2[current_block].busy_block.equal_to == NULL){
+
+ if(heapinfo1[current_block].busy_block.busy_size == heapinfo2[current_block].busy_block.busy_size){
+
+ addr_block2 = ((void*) (((ADDR2UINT(current_block)) - 1) * BLOCKSIZE + (char*)heapbase2));
+ real_addr_block2 = (char*)((xbt_mheap_t)s_heap)->heapbase + (((char *)addr_block2) - (char *)heapbase2);
+
+ if((stack_name = is_stack(real_addr_block2)) != NULL){
+ stack_region_t stack = xbt_new0(s_stack_region_t, 1);
+ stack->address = addr_block2;
+ stack->process_name = strdup(stack_name);
+ stack->size = heapinfo2[current_block].busy_block.busy_size;
+ xbt_dynar_push(*stack2, &stack);
+ }
+
+ add_heap_area_pair(previous, current_block, -1, current_block, -1);
+
+ if(ignore_done < xbt_dynar_length(mc_comparison_ignore)){
+ if(in_mc_comparison_ignore((int)current_block, -1))
+ res_compare = compare_area(addr_block1, addr_block2, heapinfo1[current_block].busy_block.busy_size, previous, 1);
+ else
+ res_compare = compare_area(addr_block1, addr_block2, heapinfo1[current_block].busy_block.busy_size, previous, 0);
+ }else{
+ res_compare = compare_area(addr_block1, addr_block2, heapinfo1[current_block].busy_block.busy_size, previous, 0);
+ }
+
+ if(res_compare == 0){
+ for(k=1; k < heapinfo2[current_block].busy_block.size; k++)
+ heapinfo2[current_block+k].busy_block.equal_to = new_heap_area(i1, -1);
+ for(k=1; k < heapinfo1[current_block].busy_block.size; k++)
+ heapinfo1[current_block+k].busy_block.equal_to = new_heap_area(i1, -1);
+ equal = 1;
+ match_equals(previous, equals);
+ i1 = i1 + heapinfo1[current_block].busy_block.size;
+ }
+
+ xbt_dynar_reset(previous);
+
+ }
+
+ }
+
+ }
+
+ while(i2 <= heaplimit && !equal){
+
+ addr_block2 = ((void*) (((ADDR2UINT(i2)) - 1) * BLOCKSIZE + (char*)heapbase2));
+ real_addr_block2 = (char*)((xbt_mheap_t)s_heap)->heapbase + (((char *)addr_block2) - (char *)heapbase2);
+
+ if((stack_name = is_stack(real_addr_block2)) != NULL){
+ stack_region_t stack = xbt_new0(s_stack_region_t, 1);
+ stack->address = addr_block2;
+ stack->process_name = strdup(stack_name);
+ stack->size = heapinfo2[i2].busy_block.busy_size;
+ xbt_dynar_push(*stack2, &stack);
+ }
+
+ if(i2 == current_block){
+ i2++;
+ continue;
+ }
+
+ if(heapinfo2[i2].type != 0){
+ i2++;
+ continue;
+ }
+
+ if(heapinfo2[i2].busy_block.equal_to != NULL){
+ i2++;
+ continue;
+ }
+
+ if(heapinfo1[i1].busy_block.size != heapinfo2[i2].busy_block.size){
+ i2++;
+ continue;
+ }
+
+ if(heapinfo1[i1].busy_block.busy_size != heapinfo2[i2].busy_block.busy_size){
+ i2++;
+ continue;
+ }
+
+ /* Comparison */
+ add_heap_area_pair(previous, i1, -1, i2, -1);
+
+ if(ignore_done < xbt_dynar_length(mc_comparison_ignore)){
+ if(in_mc_comparison_ignore((int)i1, -1))
+ res_compare = compare_area(addr_block1, addr_block2, heapinfo1[i1].busy_block.busy_size, previous, 1);
+ else
+ res_compare = compare_area(addr_block1, addr_block2, heapinfo1[i1].busy_block.busy_size, previous, 0);
+ }else{
+ res_compare = compare_area(addr_block1, addr_block2, heapinfo1[i1].busy_block.busy_size, previous, 0);
+ }
+
+ if(res_compare == 0){
+ for(k=1; k < heapinfo2[i2].busy_block.size; k++)
+ heapinfo2[i2+k].busy_block.equal_to = new_heap_area(i1, -1);
+ for(k=1; k < heapinfo1[i1].busy_block.size; k++)
+ heapinfo1[i1+k].busy_block.equal_to = new_heap_area(i2, -1);
+ equal = 1;
+ match_equals(previous, equals);
+ i1 = i1 + heapinfo1[i1].busy_block.size;
+ }
+
+ xbt_dynar_reset(previous);
+
+ i2++;
+
+ }
+
+ if(!equal)
+ i1++;
+
+ }else{ /* Fragmented block */
+
+ for(j1=0; j1 < (size_t) (BLOCKSIZE >> heapinfo1[i1].type); j1++){
+
+ current_fragment = j1;
+
+ if(heapinfo1[i1].busy_frag.frag_size[j1] == -1) /* Free fragment */
+ continue;
+
+ if(heapinfo1[i1].busy_frag.equal_to[j1] != NULL)
+ continue;
+
+ addr_frag1 = (void*) ((char *)addr_block1 + (j1 << heapinfo1[i1].type));
+
+ i2 = 1;
+ equal = 0;
+
+ /* Try first to associate to same fragment in the other heap */
+ if(heapinfo2[current_block].type == heapinfo1[current_block].type){
+
+ if(heapinfo2[current_block].busy_frag.equal_to[current_fragment] == NULL){
+
+ if(heapinfo1[current_block].busy_frag.frag_size[current_fragment] == heapinfo2[current_block].busy_frag.frag_size[current_fragment]){
+
+ addr_block2 = ((void*) (((ADDR2UINT(current_block)) - 1) * BLOCKSIZE + (char*)heapbase2));
+ addr_frag2 = (void*) ((char *)addr_block2 + (current_fragment << heapinfo2[current_block].type));
+
+ add_heap_area_pair(previous, current_block, current_fragment, current_block, current_fragment);
+
+ if(ignore_done < xbt_dynar_length(mc_comparison_ignore)){
+ if(in_mc_comparison_ignore((int)current_block, (int)current_fragment))
+ res_compare = compare_area(addr_frag1, addr_frag2, heapinfo1[current_block].busy_frag.frag_size[current_fragment], previous, 1);
+ else
+ res_compare = compare_area(addr_frag1, addr_frag2, heapinfo1[current_block].busy_frag.frag_size[current_fragment], previous, 0);
+ }else{
+ res_compare = compare_area(addr_frag1, addr_frag2, heapinfo1[current_block].busy_frag.frag_size[current_fragment], previous, 0);
+ }
+
+ if(res_compare == 0){
+ equal = 1;
+ match_equals(previous, equals);
+ }
+
+ xbt_dynar_reset(previous);
+
+ }
+
+ }
+
+ }
+
+ while(i2 <= heaplimit && !equal){
+
+
+ if(heapinfo2[i2].type <= 0){
+ i2++;
+ continue;
+ }
+
+ for(j2=0; j2 < (size_t) (BLOCKSIZE >> heapinfo2[i2].type); j2++){
+
+ if(heapinfo2[i2].type == heapinfo1[i1].type && i2 == current_block && j2 == current_fragment)
+ continue;
+
+ if(heapinfo2[i2].busy_frag.equal_to[j2] != NULL)
+ continue;
+
+ if(heapinfo1[i1].busy_frag.frag_size[j1] != heapinfo2[i2].busy_frag.frag_size[j2]) /* Different size_used */
+ continue;
+
+ addr_block2 = ((void*) (((ADDR2UINT(i2)) - 1) * BLOCKSIZE + (char*)heapbase2));
+ addr_frag2 = (void*) ((char *)addr_block2 + (j2 << heapinfo2[i2].type));
+
+ /* Comparison */
+ add_heap_area_pair(previous, i1, j1, i2, j2);
+
+ if(ignore_done < xbt_dynar_length(mc_comparison_ignore)){
+ if(in_mc_comparison_ignore((int)i1, (int)j1))
+ res_compare = compare_area(addr_frag1, addr_frag2, heapinfo1[i1].busy_frag.frag_size[j1], previous, 1);
+ else
+ res_compare = compare_area(addr_frag1, addr_frag2, heapinfo1[i1].busy_frag.frag_size[j1], previous, 0);
+ }else{
+ res_compare = compare_area(addr_frag1, addr_frag2, heapinfo1[i1].busy_frag.frag_size[j1], previous, 0);
+ }
+
+ if(res_compare == 0){
+ equal = 1;
+ match_equals(previous, equals);
+ break;
+ }
+
+ xbt_dynar_reset(previous);
+
+ }
+
+ i2++;
+
+ }
+
+ }
+
+ i1++;
+
+ }