+
+ }
+}
+
+/** Check whether two blocks are known to be matching
+ *
+ * @param state State used
+ * @param b1 Block of state 1
+ * @param b2 Block of state 2
+ * @return if the blocks are known to be matching
+ */
+static int equal_blocks(struct s_mm_diff *state, int b1, int b2){
+
+ if(state->equals_to1_(b1,0)->block == b2 && state->equals_to2_(b2,0)->block == b1)
+ return 1;
+
+ return 0;
+}
+
+/** Check whether two fragments are known to be matching
+ *
+ * @param state State used
+ * @param b1 Block of state 1
+ * @param f1 Fragment of state 1
+ * @param b2 Block of state 2
+ * @param f2 Fragment of state 2
+ * @return if the fragments are known to be matching
+ */
+static int equal_fragments(struct s_mm_diff *state, int b1, int f1, int b2, int f2){
+
+ if(state->equals_to1_(b1,f1)->block == b2
+ && state->equals_to1_(b1,f1)->fragment == f2
+ && state->equals_to2_(b2,f2)->block == b1
+ && state->equals_to2_(b2,f2)->fragment == f1)
+ return 1;
+
+ return 0;
+}
+
+int init_heap_information(xbt_mheap_t heap1, xbt_mheap_t heap2, xbt_dynar_t i1, xbt_dynar_t i2){
+ if(mm_diff_info==NULL) {
+ mm_diff_info = xbt_new0(struct s_mm_diff, 1);
+ }
+ struct s_mm_diff *state = mm_diff_info;
+
+ if((((struct mdesc *)heap1)->heaplimit != ((struct mdesc *)heap2)->heaplimit)
+ || ((((struct mdesc *)heap1)->heapsize != ((struct mdesc *)heap2)->heapsize) ))
+ return -1;
+
+ state->heaplimit = ((struct mdesc *)heap1)->heaplimit;
+
+ state->s_heap = (char *)mmalloc_get_current_heap() - STD_HEAP_SIZE - xbt_pagesize;
+
+ state->heapbase1 = (char *)heap1 + BLOCKSIZE;
+ state->heapbase2 = (char *)heap2 + BLOCKSIZE;
+
+ state->heapinfo1 = (malloc_info *)((char *)heap1 + ((uintptr_t)((char *)((struct mdesc *)heap1)->heapinfo - (char *)state->s_heap)));
+ state->heapinfo2 = (malloc_info *)((char *)heap2 + ((uintptr_t)((char *)((struct mdesc *)heap2)->heapinfo - (char *)state->s_heap)));
+
+ state->heapsize1 = heap1->heapsize;
+ state->heapsize2 = heap2->heapsize;
+
+ state->to_ignore1 = i1;
+ state-> to_ignore2 = i2;
+
+ state->equals_to1 = calloc(state->heaplimit * MAX_FRAGMENT_PER_BLOCK, sizeof(heap_area_t *));
+ state->types1 = calloc(state->heaplimit * MAX_FRAGMENT_PER_BLOCK, sizeof(type_name *));
+ state->equals_to2 = calloc(state->heaplimit * MAX_FRAGMENT_PER_BLOCK, sizeof(heap_area_t *));
+ state->types2 = calloc(state->heaplimit * MAX_FRAGMENT_PER_BLOCK, sizeof(type_name *));
+
+ state->available = state->heaplimit;
+
+ if(MC_is_active()){
+ MC_ignore_global_variable("mm_diff_info");
+ }
+
+ return 0;
+
+}
+
+void reset_heap_information(){
+
+ struct s_mm_diff *state = mm_diff_info;
+
+ size_t i;
+ for(i=0; i!=state->heaplimit * MAX_FRAGMENT_PER_BLOCK; ++i)
+ xbt_free(state->equals_to1[i]);
+ for(i=0; i!=state->heaplimit * MAX_FRAGMENT_PER_BLOCK; ++i)
+ xbt_free(state->equals_to2[i]);
+
+ free(state->equals_to1);
+ free(state->equals_to2);
+ free(state->types1);
+ free(state->types2);
+
+ state->s_heap = NULL, state->heapbase1 = NULL, state->heapbase2 = NULL;
+ state->heapinfo1 = NULL, state->heapinfo2 = NULL;
+ state->heaplimit = 0, state->heapsize1 = 0, state->heapsize2 = 0;
+ state->to_ignore1 = NULL, state->to_ignore2 = NULL;
+ state->equals_to1 = NULL, state->equals_to2 = NULL;
+ state->types1 = NULL, state->types2 = NULL;
+
+}
+
+int mmalloc_compare_heap(mc_snapshot_t snapshot1, mc_snapshot_t snapshot2, xbt_mheap_t heap1, xbt_mheap_t heap2){
+
+ struct s_mm_diff *state = mm_diff_info;
+
+ if(heap1 == NULL && heap2 == NULL){
+ XBT_DEBUG("Malloc descriptors null");
+ return 0;