/* lib - a generic library, variation over dictionary */
-/* Copyright (c) 2011. The SimGrid Team.
+/* Copyright (c) 2011, 2013. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
{
xbt_lib_t lib;
lib = xbt_new(s_xbt_lib_t, 1);
- lib->dict = xbt_dict_new();
+ lib->dict = xbt_dict_new_homogeneous(xbt_free);
lib->levels = 0;
lib->free_f = NULL;
return lib;
void **elts = xbt_dict_get_or_null(lib->dict, key);
if (!elts) {
elts = xbt_new0(void *, lib->levels);
- xbt_dict_set(lib->dict, key, elts, xbt_free);
+ xbt_dict_set(lib->dict, key, elts, NULL);
}
if (elts[level]) {
XBT_DEBUG("Replace %p by %p element under key '%s:%d'",
void **elts = xbt_dict_get_or_null(lib->dict, key);
return elts ? elts[level] : NULL;
}
+
+xbt_dictelm_t xbt_lib_get_elm_or_null(xbt_lib_t lib, const char *key)
+{
+ return xbt_dict_get_elm_or_null(lib->dict, key);
+}
+
+void *xbt_lib_get_level(xbt_dictelm_t elm, int level){
+ void **elts = elm->content;
+ return elts ? elts[level] : NULL;
+}