static xbt_mallocator_t dict_mallocator = NULL;
static void *dict_mallocator_new_f(void);
-static void dict_mallocator_free_f(void *dict);
-static void dict_mallocator_reset_f(void *dict);
+#define dict_mallocator_free_f xbt_free_f
+#define dict_mallocator_reset_f ((void_f_pvoid_t)NULL)
/*####[ Code ]###############################################################*/
/**
* \brief Constructor
* \return pointer to the destination
- * \see xbt_dict_new_ext(), xbt_dict_free()
+ * \see xbt_dict_free()
*
* Creates and initialize a new dictionary with a default hashtable size.
*/
}
if (current == NULL)
- THROW2(not_found_error, 0, "key %.*s not found", key_len, key);
+ THROWF(not_found_error, 0, "key %.*s not found", key_len, key);
return current->content;
}
current = current->next;
if (current == NULL)
- THROW1(not_found_error, 0, "key %s not found", key);
+ THROWF(not_found_error, 0, "key %s not found", key);
return current->content;
}
}
if (current == NULL)
- THROW2(not_found_error, 0, "key %.*s not found", key_len, key);
+ THROWF(not_found_error, 0, "key %.*s not found", key_len, key);
if (previous != NULL) {
previous->next = current->next;
}
if (current == NULL)
- THROW1(not_found_error, 0, "key %zu not found", key);
+ THROWF(not_found_error, 0, "key %zu not found", key);
if (previous != NULL) {
previous->next = current->next;
*/
XBT_INLINE int xbt_dict_is_empty(xbt_dict_t dict)
{
- return (xbt_dict_size(dict) == 0);
+ return !dict || (xbt_dict_length(dict) == 0);
}
/**
while (element != NULL) {
printf(" %s -> '", element->key);
if (output != NULL) {
- (*output) (element->content);
+ output(element->content);
}
printf("'\n");
element = element->next;
return xbt_new(s_xbt_dict_t, 1);
}
-static void dict_mallocator_free_f(void *dict)
-{
- xbt_free(dict);
-}
-
-static void dict_mallocator_reset_f(void *dict)
-{
- /* nothing to do because all fields are
- * initialized in xbt_dict_new
- */
-}
-
#ifdef SIMGRID_TEST
#include "xbt.h"
#include "xbt/ex.h"
TRY {
data = xbt_dict_get(head, data);
- THROW1(unknown_error, 0,
+ THROWF(unknown_error, 0,
"Found something which shouldn't be there (%s)", data);
- } CATCH(e) {
+ }
+ CATCH(e) {
if (e.category != not_found_error)
xbt_test_exception(e);
xbt_ex_free(e);
static void count_check_get_key(xbt_dict_t dict, int length)
{
xbt_dict_cursor_t cursor;
- char *key, *key2;
+ char *key;
+ _XBT_GNUC_UNUSED char *key2;
void *data;
int effective = 0;
xbt_dict_foreach(dict, cursor, key, data) {
effective++;
key2 = xbt_dict_get_key(dict, data);
- xbt_assert2(!strcmp(key, key2),
+ xbt_assert(!strcmp(key, key2),
"The data was registered under %s instead of %s as expected",
key2, key);
}
traverse(head);
TRY {
debuged_remove(head, "12346");
- } CATCH(e) {
+ }
+ CATCH(e) {
if (e.category != not_found_error)
xbt_test_exception(e);
xbt_ex_free(e);
XBT_TEST_UNIT("crash", test_dict_crash, "Crash test")
{
xbt_dict_t head = NULL;
- int i, j, k, nb;
+ int i, j, k;
char *key;
void *data;
SIZEOFKEY);
head = xbt_dict_new();
/* if (i%10) printf("."); else printf("%d",i/10); fflush(stdout); */
- nb = 0;
for (j = 0; j < 1000; j++) {
char *data = NULL;
key = xbt_malloc(SIZEOFKEY);