/* mallocator - recycle objects to avoid malloc() / free() */
-/* Copyright (c) 2006-2011. The SimGrid Team.
+/* Copyright (c) 2006-2014. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* mallocators should be protected from concurrent accesses. */
static int initialization_done = 0;
-static XBT_INLINE void lock_create(xbt_mallocator_t m)
+static XBT_INLINE void lock_reset(xbt_mallocator_t m)
{
m->lock = 0;
}
-static XBT_INLINE void lock_destroy(xbt_mallocator_t m)
-{
-}
-
static XBT_INLINE void lock_acquire(xbt_mallocator_t m)
{
if (initialization_done > 1) {
m->free_f(m->objects[i]);
}
xbt_free(m->objects);
- lock_destroy(m);
xbt_free(m);
}
if (xbt_mallocator_is_active()) {
// We have to switch this mallocator from inactive to active (and then get an object)
m->objects = xbt_new0(void *, m->max_size);
- lock_create(m);
+ lock_reset(m);
return xbt_mallocator_get(m);
} else {
object = m->new_f();
if (xbt_mallocator_is_active()) {
// We have to switch this mallocator from inactive to active (and then store that object)
m->objects = xbt_new0(void *, m->max_size);
- lock_create(m);
+ lock_reset(m);
xbt_mallocator_release(m,object);
} else {
m->free_f(object);