Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
test dict before giving its size...
[simgrid.git] / src / xbt / dict.c
index af51012..b9079c6 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);
 }
 
 /**
@@ -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)