- * \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 reinitialise an object of your datatype, called
- * when you extract an object from the mallocator (can be NULL)
+ * 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)