if (dict != NULL && *dict != NULL) {
table_size = (*dict)->table_size;
table = (*dict)->table;
- for (i = 0; i < table_size; i++) {
+ for (i = 0; (*dict)->count && i < table_size; i++) {
current = table[i];
while (current != NULL) {
previous = current;
current = current->next;
xbt_dictelm_free(previous);
+ (*dict)->count--;
}
}
xbt_free(table);
}
}
+/**
+ * Returns the amount of elements in the dict
+ */
+unsigned int xbt_dict_size(xbt_dict_t dict) {
+ return dict->count;
+}
+
/**
* Returns the hash code of a string.
*/
int i;
unsigned int count;
- int size;
+ unsigned int size;
xbt_dictelm_t element;
xbt_dynar_t sizes = xbt_dynar_new(sizeof(int),NULL);
continue;
if (size==0)
continue;
- printf("%delm x %d cells; ",count,size);
+ printf("%delm x %u cells; ",count,size);
}
}
printf("\n");