A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Reset an object only when the user needs it
[simgrid.git]
/
src
/
xbt
/
mallocator.c
diff --git
a/src/xbt/mallocator.c
b/src/xbt/mallocator.c
index
52d7702
..
c2b1d3c
100644
(file)
--- a/
src/xbt/mallocator.c
+++ b/
src/xbt/mallocator.c
@@
-41,14
+41,14
@@
void *xbt_mallocator_get(xbt_mallocator_t m) {
void *object;
if (m->current_size > 0) {
/* there is at least an available object */
void *object;
if (m->current_size > 0) {
/* there is at least an available object */
-
return
m->objects[--m->current_size];
+
object =
m->objects[--m->current_size];
}
else {
/* otherwise we must allocate a new object */
object = m->new_f();
}
else {
/* otherwise we must allocate a new object */
object = m->new_f();
- m->reset_f(object);
- return object;
}
}
+ m->reset_f(object);
+ return object;
}
/* Release an object (use this function instead of free) */
}
/* Release an object (use this function instead of free) */
@@
-57,7
+57,6
@@
void xbt_mallocator_release(xbt_mallocator_t m, void *object) {
if (m->current_size < m->max_size) {
/* there is enough place to push the object */
if (m->current_size < m->max_size) {
/* there is enough place to push the object */
- m->reset_f(object);
m->objects[m->current_size++] = object;
}
else {
m->objects[m->current_size++] = object;
}
else {