Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
removing misplaced code (was moved from here before routing update)
[simgrid.git] / src / xbt / dict.c
index 4f507cb..708cffb 100644 (file)
@@ -89,7 +89,7 @@ void xbt_dict_free(xbt_dict_t * dict)
  */
 XBT_INLINE unsigned int xbt_dict_size(xbt_dict_t dict)
 {
-  return dict->count;
+  return (dict ? (unsigned int) dict->count : (unsigned int) 0);
 }
 
 /**
@@ -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)
@@ -637,7 +637,13 @@ void xbt_dict_dump_output_string(void *s)
 {
   fputs(s, stdout);
 }
-
+/**
+ * \brief test if the dict is empty or not
+ */
+XBT_INLINE int xbt_dict_is_empty(xbt_dict_t dict)
+{
+       return (xbt_dict_size(dict) == 0);
+}
 
 /**
  * \brief Outputs the content of the structure (debugging purpose)
@@ -811,8 +817,7 @@ static void dict_mallocator_reset_f(void *dict)
 #include "portable.h"
 
 XBT_LOG_EXTERNAL_CATEGORY(xbt_dict);
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_dict, xbt,
-                                "Dictionaries provide the same functionalities than hash tables");
+XBT_LOG_DEFAULT_CATEGORY(xbt_dict);
 
 XBT_TEST_SUITE("dict", "Dict data container");