+static inline void lock_release(xbt_mallocator_t m)
+{
+ if (initialization_done > 1)
+ atomic_flag_clear(&m->lock);
+}
+
+/**
+ * This function must be called once the framework configuration is done. mallocators will not get used until it's
+ * called (check the implementation notes above for more info).
+ *
+ * sg_config uses this function to inform the mallocators when simgrid is configured, and whether lock protection is
+ * needed.
+ */
+void xbt_mallocator_initialization_is_done(int need_protection)
+{
+ initialization_done = need_protection ? 2 : 1;
+}
+
+/** used by the module to know if it's time to activate the mallocators yet */
+static inline int xbt_mallocator_is_active(void) {
+#if SIMGRID_HAVE_MALLOCATOR
+ return initialization_done && !MC_is_active();
+#else
+ return 0;
+#endif
+}
+
+/**
+ * @brief Constructor
+ * @param size size of the internal stack: number of objects the mallocator will be able to store
+ * @param new_f function to allocate a new object of your datatype, called in @a xbt_mallocator_get() when the
+ * mallocator is empty
+ * @param free_f function to free an object of your datatype, called in @a xbt_mallocator_release() when the stack is
+ * full, and when the mallocator is freed.
+ * @param reset_f function to reinitialize an object of your datatype, called when you extract an object from the
+ * mallocator (can be NULL)
+ *
+ * Create and initialize a new mallocator for a given datatype.
+ *
+ * @return pointer to the created mallocator
+ * @see xbt_mallocator_free()
+ */
+xbt_mallocator_t xbt_mallocator_new(int size, pvoid_f_void_t new_f, void_f_pvoid_t free_f, void_f_pvoid_t reset_f)
+{