- if (m->current_size <= 0) {
- /* No object is ready yet. Create a bunch of them to try to group the mallocs
- * on the same memory pages (to help the cache lines) */
-
- /* XBT_DEBUG("Create a new object for mallocator %p (size:%d/%d)", m,
- m->current_size, m->max_size); */
- int i;
- int amount=MIN( (m->max_size) /2,1000);
- for (i=0;i<amount;i++)
- m->objects[i] = (*(m->new_f)) ();
- m->current_size=amount;
- }
-
- /* there is at least an available object, now */
- /* XBT_DEBUG("Reuse an old object for mallocator %p (size:%d/%d)", m,
- m->current_size, m->max_size); */
- if (MC_IS_ENABLED) /* no mallocator with MC */
- object = (*(m->new_f)) ();
- else
+ if (MALLOCATOR_IS_ENABLED) {
+ xbt_os_mutex_acquire(m->mutex);
+ if (m->current_size <= 0) {
+ /* No object is ready yet. Create a bunch of them to try to group the
+ * mallocs on the same memory pages (to help the cache lines) */
+
+ /* XBT_DEBUG("Create a new object for mallocator %p (size:%d/%d)", */
+ /* m, m->current_size, m->max_size); */
+ int i;
+ int amount = MIN(m->max_size / 2, 1000);
+ for (i = 0; i < amount; i++)
+ m->objects[i] = m->new_f();
+ m->current_size = amount;
+ }
+
+ /* there is at least an available object, now */
+ /* XBT_DEBUG("Reuse an old object for mallocator %p (size:%d/%d)", */
+ /* m, m->current_size, m->max_size); */