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
Typo.
[simgrid.git]
/
src
/
xbt
/
lib.c
diff --git
a/src/xbt/lib.c
b/src/xbt/lib.c
index
8c594cf
..
953666c
100644
(file)
--- a/
src/xbt/lib.c
+++ b/
src/xbt/lib.c
@@
-17,7
+17,7
@@
xbt_lib_t xbt_lib_new(void)
{
xbt_lib_t lib;
lib = xbt_new(s_xbt_lib_t, 1);
- lib->dict = xbt_dict_new_homogeneous(xbt_free);
+ lib->dict = xbt_dict_new_homogeneous(xbt_free
_f
);
lib->levels = 0;
lib->free_f = NULL;
return lib;
@@
-80,25
+80,28
@@
void xbt_lib_unset(xbt_lib_t lib, const char *key, int level, int invoke_callbac
}
void *obj = elts[level];
-
if (!obj) {
XBT_WARN("no key %s at level %d", key, level);
- } else {
- XBT_DEBUG("Remove %p of key %s at level %d", obj, key, level);
- if (invoke_callback)
- lib->free_f[level](obj);
- elts[level] = NULL;
+ return;
}
+ XBT_DEBUG("Remove %p of key %s at level %d", obj, key, level);
+ elts[level] = NULL;
+
/* check if there still remains any elements of this key */
+ int empty = 1;
int i;
- for (i = 0; i < lib->levels; i++) {
+ for (i = 0; i < lib->levels
&& empty
; i++) {
if (elts[i] != NULL)
- return;
+ empty = 0;
+ }
+ if (empty) {
+ /* there is no element at any level, so delete the key */
+ xbt_dict_remove(lib->dict, key);
}
- /* there is no element at any level, so delete the key */
-
xbt_dict_remove(lib->dict, key
);
+ if (invoke_callback)
+
lib->free_f[level](obj
);
}
void *xbt_lib_get_or_null(xbt_lib_t lib, const char *key, int level)