X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/3d0d626e19a7b79320e7d922c9c1dcf122076cea..fd28ea3d66eee426ac29108bc8a5d4f017dc326d:/src/xbt/dict.c diff --git a/src/xbt/dict.c b/src/xbt/dict.c index 3bf65c2836..2a79ff183f 100644 --- a/src/xbt/dict.c +++ b/src/xbt/dict.c @@ -8,8 +8,6 @@ /* This program is free software; you can redistribute it and/or modify it under the terms of the license (GNU LGPL) which comes with this package. */ - -#include "gras_private.h" #include "dict_private.h" #include /* malloc() */ @@ -17,7 +15,7 @@ #include -GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(dict,gros, +GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(dict,xbt, "Dictionaries provide the same functionnalities than hash tables"); /*####[ Private prototypes ]#################################################*/ @@ -32,12 +30,11 @@ GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(dict,gros, * * Creates and initialize a new dictionnary */ -void -gras_dict_new(gras_dict_t **whereto) { - - (*whereto) = gras_new(gras_dict_t,1); - (*whereto)->head=NULL; - +gras_dict_t +gras_dict_new(void) { + gras_dict_t res= gras_new(s_gras_dict_t,1); + res->head=NULL; + return res; } /** * gras_dict_free: @@ -46,13 +43,13 @@ gras_dict_new(gras_dict_t **whereto) { * Frees a cache structure with all its childs. */ void -gras_dict_free(gras_dict_t **dict) { +gras_dict_free(gras_dict_t *dict) { if (dict && *dict) { if ((*dict)->head) { gras_dictelm_free( &( (*dict)->head ) ); (*dict)->head = NULL; } - free(*dict); + gras_free(*dict); *dict=NULL; } } @@ -69,15 +66,15 @@ gras_dict_free(gras_dict_t **dict) { * of data, as long as its length is provided in @key_len. */ void -gras_dict_set_ext(gras_dict_t *p_dict, +gras_dict_set_ext(gras_dict_t dict, const char *key, int key_len, void *data, void_f_pvoid_t *free_ctn) { - gras_assert(p_dict); + gras_assert(dict); - gras_dictelm_set_ext(&(p_dict->head), + gras_dictelm_set_ext(&(dict->head), key, key_len, data, free_ctn); } @@ -93,14 +90,14 @@ gras_dict_set_ext(gras_dict_t *p_dict, * null terminated string. */ void -gras_dict_set(gras_dict_t *p_dict, - const char *key, - void *data, - void_f_pvoid_t *free_ctn) { +gras_dict_set(gras_dict_t dict, + const char *key, + void *data, + void_f_pvoid_t *free_ctn) { - gras_assert(p_dict); + gras_assert(dict); - gras_dictelm_set(&(p_dict->head), key, data, free_ctn); + gras_dictelm_set(&(dict->head), key, data, free_ctn); } /** @@ -114,10 +111,10 @@ gras_dict_set(gras_dict_t *p_dict, * Search the given @key. mismatch_error when not found. */ gras_error_t -gras_dict_get_ext(gras_dict_t *dict, - const char *key, - int key_len, - /* OUT */void **data) { +gras_dict_get_ext(gras_dict_t dict, + const char *key, + int key_len, + /* OUT */void **data) { gras_assert(dict); @@ -135,9 +132,9 @@ gras_dict_get_ext(gras_dict_t *dict, * Search the given @key. mismatch_error when not found. */ gras_error_t -gras_dict_get(gras_dict_t *dict, - const char *key, - /* OUT */void **data) { +gras_dict_get(gras_dict_t dict, + const char *key, + /* OUT */void **data) { gras_assert(dict); return gras_dictelm_get(dict->head, key, data); @@ -154,7 +151,7 @@ gras_dict_get(gras_dict_t *dict, * Remove the entry associated with the given @key */ gras_error_t -gras_dict_remove_ext(gras_dict_t *dict, +gras_dict_remove_ext(gras_dict_t dict, const char *key, int key_len) { gras_assert(dict); @@ -172,7 +169,7 @@ gras_dict_remove_ext(gras_dict_t *dict, * Remove the entry associated with the given @key */ gras_error_t -gras_dict_remove(gras_dict_t *dict, +gras_dict_remove(gras_dict_t dict, const char *key) { if (!dict) RAISE1(mismatch_error,"Asked to remove key %s from NULL dict",key); @@ -193,7 +190,7 @@ gras_dict_remove(gras_dict_t *dict, */ void -gras_dict_dump(gras_dict_t *dict, +gras_dict_dump(gras_dict_t dict, void_f_pvoid_t *output) { printf("Dict %p:\n", (void*)dict);