Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Cleanup heap switching code
[simgrid.git] / src / xbt / mmalloc / mm_legacy.c
index d4f75a3..fac98b1 100644 (file)
@@ -40,9 +40,11 @@ xbt_mheap_t mmalloc_get_current_heap(void)
   return __mmalloc_current_heap;
 }
 
-void mmalloc_set_current_heap(xbt_mheap_t new_heap)
+xbt_mheap_t mmalloc_set_current_heap(xbt_mheap_t new_heap)
 {
+  xbt_mheap_t heap = __mmalloc_current_heap;
   __mmalloc_current_heap = new_heap;
+  return heap;
 }
 
 #ifdef MMALLOC_WANT_OVERRIDE_LEGACY
@@ -84,6 +86,22 @@ static void __attribute__((constructor(101))) mm_legacy_constructor()
   }
 }
 
+void* malloc_no_memset(size_t n)
+{
+  if (!__malloc_use_mmalloc) {
+    return mm_real_malloc(n);
+  }
+
+  xbt_mheap_t mdp = GET_HEAP();
+  if (!mdp)
+    return NULL;
+
+  LOCK(mdp);
+  void *ret = mmalloc_no_memset(mdp, n);
+  UNLOCK(mdp);
+  return ret;
+}
+
 void *malloc(size_t n)
 {
   if (!__malloc_use_mmalloc) {