- if (mdp) {
- LOCK(mdp);
- ret = mmalloc(mdp, n);
- UNLOCK(mdp);
-#ifdef MM_LEGACY_VERBOSE
- if (!warned_mmalloc) {
- fprintf(stderr,"Using mmalloc; enabling the model-checker in cmake may have a bad impact on your simulation performance\n");
- warned_mmalloc = 1;
- }
-#endif
+static void mm_fake_free(XBT_ATTRIB_UNUSED void* p)
+{
+ // Nothing to do
+}
+
+/* Function signatures for the main malloc functions: */
+typedef void* (*mm_malloc_t)(size_t size);
+typedef void (*mm_free_t)(void*);
+typedef void* (*mm_calloc_t)(size_t nmemb, size_t size);
+typedef void* (*mm_realloc_t)(void *ptr, size_t size);
+
+/* Function pointers to the real/next implementations: */
+static mm_malloc_t mm_real_malloc;
+static mm_free_t mm_real_free;
+static mm_calloc_t mm_real_calloc;
+static mm_realloc_t mm_real_realloc;
+
+static int mm_initializing;
+static int mm_initialized;
+
+/** Constructor functions used to initialize the malloc implementation
+ */
+XBT_ATTRIB_CONSTRUCTOR(101) static void mm_legacy_constructor()
+{
+ if (mm_initialized)
+ return;
+ mm_initializing = 1;
+ __malloc_use_mmalloc = getenv(MC_ENV_VARIABLE) ? 1 : 0;
+ if (__malloc_use_mmalloc) {
+ __mmalloc_current_heap = mmalloc_preinit();