From 329823f4f8ac806d1ac58d48bbbf98c2b1d43b01 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Fri, 25 Nov 2011 18:45:13 +0100 Subject: [PATCH 1/1] Add a dict parameter to dictelm functions. Unused for now. --- src/xbt/dict.c | 8 ++++---- src/xbt/dict_elm.c | 9 ++++----- src/xbt/dict_private.h | 4 ++-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/xbt/dict.c b/src/xbt/dict.c index 4ec20c9d4e..4bbe272342 100644 --- a/src/xbt/dict.c +++ b/src/xbt/dict.c @@ -67,7 +67,7 @@ void xbt_dict_free(xbt_dict_t * dict) while (current != NULL) { previous = current; current = current->next; - xbt_dictelm_free(previous); + xbt_dictelm_free(*dict, previous); (*dict)->count--; } } @@ -244,7 +244,7 @@ XBT_INLINE void xbt_dict_set_ext(xbt_dict_t dict, if (current == NULL) { /* this key doesn't exist yet */ - current = xbt_dictelm_new(key, key_len, hash_code, data, free_ctn); + current = xbt_dictelm_new(dict, key, key_len, hash_code, data, free_ctn); dict->count++; if (previous == NULL) { dict->table[hash_code & dict->table_size] = current; @@ -461,7 +461,7 @@ XBT_INLINE void xbt_dict_remove_ext(xbt_dict_t dict, const char *key, if (!dict->table[hash_code & dict->table_size]) dict->fill--; - xbt_dictelm_free(current); + xbt_dictelm_free(dict, current); dict->count--; } @@ -536,7 +536,7 @@ void xbt_dict_reset(xbt_dict_t dict) while (current != NULL) { previous = current; current = current->next; - xbt_dictelm_free(previous); + xbt_dictelm_free(dict, previous); } dict->table[i] = NULL; } diff --git a/src/xbt/dict_elm.c b/src/xbt/dict_elm.c index cda2c44aa9..ab3ae5bb7d 100644 --- a/src/xbt/dict_elm.c +++ b/src/xbt/dict_elm.c @@ -23,10 +23,9 @@ XBT_LOG_NEW_SUBCATEGORY(xbt_dict_collapse, xbt_dict, xbt_mallocator_t dict_elm_mallocator = NULL; -xbt_dictelm_t xbt_dictelm_new(const char *key, - int key_len, - unsigned int hash_code, - void *content, void_f_pvoid_t free_f) +xbt_dictelm_t xbt_dictelm_new(xbt_dict_t dict, const char *key, int key_len, + unsigned int hash_code, void *content, + void_f_pvoid_t free_f) { xbt_dictelm_t element = xbt_mallocator_get(dict_elm_mallocator); @@ -44,7 +43,7 @@ xbt_dictelm_t xbt_dictelm_new(const char *key, return element; } -void xbt_dictelm_free(xbt_dictelm_t element) +void xbt_dictelm_free(xbt_dict_t dict, xbt_dictelm_t element) { if (element != NULL) { xbt_free(element->key); diff --git a/src/xbt/dict_private.h b/src/xbt/dict_private.h index c25f8d939f..a641b51d92 100644 --- a/src/xbt/dict_private.h +++ b/src/xbt/dict_private.h @@ -49,9 +49,9 @@ extern void *dict_elm_mallocator_new_f(void); #define dict_elm_mallocator_reset_f ((void_f_pvoid_t)NULL) /*####[ Function prototypes ]################################################*/ -xbt_dictelm_t xbt_dictelm_new(const char *key, int key_len, +xbt_dictelm_t xbt_dictelm_new(xbt_dict_t dict, const char *key, int key_len, unsigned int hash_code, void *content, void_f_pvoid_t free_f); -void xbt_dictelm_free(xbt_dictelm_t element); +void xbt_dictelm_free(xbt_dict_t dict, xbt_dictelm_t element); #endif /* _XBT_DICT_PRIVATE_H_ */ -- 2.20.1