+xbt_dict_t xbt_dict_new(void) {
+ return xbt_dict_new_ext(256);
+}
+
+/**
+ * \brief Create a new dictionary with the specified hashtable size
+ * \param hashsize the hashtable size
+ * \return a pointer to the created object
+ * \see xbt_dict_new(), xbt_dict_free()
+ */
+xbt_dict_t xbt_dict_new_ext(int hashsize) {
+ int i;
+ xbt_dict_t dict = xbt_new0(s_xbt_dict_t, 1);
+ dict->table_size = hashsize;
+ dict->table = xbt_new0(xbt_dictelm_t, dict->table_size);
+
+ for (i = 0; i < hashsize; i++) {
+ dict->table[i] = NULL;
+ }
+ dict->count = 0;
+
+ return dict;
+}
+
+/**
+ * \brief Destructor
+ * \param dict the dictionnary to be freed
+ *
+ * Frees a dictionary with all the data
+ */
+void xbt_dict_free(xbt_dict_t *dict) {
+ int i;
+ xbt_dictelm_t current, previous;
+ if (dict != NULL && *dict != NULL) {
+ for (i = 0; i < (*dict)->table_size; i++) {
+ current = (*dict)->table[i];
+ while (current != NULL) {
+ previous = current;
+ current = current->next;
+ xbt_dictelm_free(previous);
+ }
+ }
+ xbt_free((*dict)->table);
+ xbt_free(*dict);
+ *dict = NULL;
+ }