Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix a 3 years old bug in the dictionary's function xbt_dict_get_or_null().
authorcristianrosa <cristianrosa@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 28 Sep 2010 13:49:44 +0000 (13:49 +0000)
committercristianrosa <cristianrosa@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 28 Sep 2010 13:49:44 +0000 (13:49 +0000)
It was broken when the hash_code of two elements collisioned.

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@8288 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/xbt/dict.c

index b9079c6..708cffb 100644 (file)
@@ -411,7 +411,7 @@ XBT_INLINE void *xbt_dict_get_or_null(xbt_dict_t dict, const char *key)
 
   current = dict->table[hash_code & dict->table_size];
   while (current != NULL &&
-         hash_code != current->hash_code && strcmp(key, current->key))
+         (hash_code != current->hash_code || strcmp(key, current->key)))
     current = current->next;
 
   if (current == NULL)