X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/cc40832e8f3a22ad82ecb43143d8759248eb8093..f3507930c130404d05f982cf9fe960fb95f7eb4b:/src/xbt/dict.c diff --git a/src/xbt/dict.c b/src/xbt/dict.c index 36e91515a5..378bdbf9ac 100644 --- a/src/xbt/dict.c +++ b/src/xbt/dict.c @@ -301,17 +301,22 @@ void *xbt_dict_get(xbt_dict_t dict, */ void *xbt_dict_get_or_null(xbt_dict_t dict, const char *key) { - xbt_ex_t e; - void *result = NULL; - TRY { - result = xbt_dict_get(dict, key); - } CATCH(e) { - if (e.category != not_found_error) - RETHROW; - xbt_ex_free(e); - result = NULL; + unsigned int hash_code ; + xbt_dictelm_t current; + + xbt_assert(dict); + + hash_code = xbt_dict_hash(key) % dict->table_size; + + current = dict->table[hash_code]; + while (current != NULL && (strcmp(key, current->key))) { + current = current->next; } - return result; + + if (current == NULL) + return NULL; + + return current->content; }