-/* Release an object (use this function instead of free) */
-void xbt_mallocator_release(xbt_mallocator_t m, void *object) {
- xbt_assert0(m != NULL && object != NULL, "Invalid parameter");
-
- if (m->current_size < m->max_size) {
- /* there is enough place to push the object */
- m->objects[m->current_size++] = object;
- }
- else {
- /* otherwise we don't have a choice, we must free the object */
+/** \brief Push an object into a mallocator
+ * \param m a mallocator
+ * \param object an object you don't need anymore
+ *
+ * Push into the mallocator an object you don't need anymore.
+ * This function is designed to be used instead of free().
+ * If the mallocator is not full, your object if stored into
+ * the mallocator and no free is done.
+ * If the mallocator is full, the object is freed by calling
+ * the function free_f().
+ *
+ * \see xbt_mallocator_get()
+ */
+void xbt_mallocator_release(xbt_mallocator_t m, void *object)
+{
+ if (MALLOCATOR_IS_ENABLED) {
+ xbt_os_mutex_acquire(m->mutex);
+ if (m->current_size < m->max_size) {
+ /* there is enough place to push the object */
+ /* XBT_DEBUG
+ ("Store deleted object in mallocator %p for further use (size:%d/%d)",
+ m, m->current_size, m->max_size); */
+ m->objects[m->current_size++] = object;
+ xbt_os_mutex_release(m->mutex);
+ } else {
+ xbt_os_mutex_release(m->mutex);
+ /* otherwise we don't have a choice, we must free the object */
+ /* XBT_DEBUG("Free deleted object: mallocator %p is full (size:%d/%d)", m,
+ m->current_size, m->max_size); */
+ m->free_f(object);
+ }
+ } else {