+ DEBUG5("ADD %zu->%zu; hash = %d, size = %d, & = %d", key, data, hash_code,
+ dict->table_size, hash_code & dict->table_size);
+ current = dict->table[hash_code & dict->table_size];
+ while (current != NULL &&
+ (hash_code != current->hash_code || sizeof(uintptr_t) != current->key_len
+ || (((uintptr_t)key) != ((uintptr_t)current->key)) )) {
+ current = current->next;
+ }
+
+ if (current == NULL) {
+ /* this key doesn't exist yet */
+ current = xbt_dictielm_new(key, hash_code, data);
+ dict->count++;
+ if (previous == NULL) {
+ dict->table[hash_code & dict->table_size] = current;
+ dict->fill++;
+ if ((dict->fill * 100) / (dict->table_size + 1) > MAX_FILL_PERCENT)
+ xbt_dict_rehash(dict);
+ } else {
+ previous->next = current;
+ }
+ } else {
+
+ /* there is already an element with the same key: overwrite it */
+ if (current->content != NULL && current->free_f != NULL) {
+ current->free_f(current->content);
+ }
+ current->content = (void*)data;
+ current->free_f = NULL;
+ }
+}
+
+/**
+ * \brief Retrieve data from the dict (key considered as a uintptr_t)
+ *
+ * \param dict the dealer of data
+ * \param key the key to find data
+ * \return the data that we are looking for (or 0 if not found)
+ *
+ * Mixing uintptr_t keys with regular keys in the same dict is discouraged
+ */
+XBT_INLINE uintptr_t xbt_dicti_get(xbt_dict_t dict, uintptr_t key) {
+
+ unsigned int hash_code = xbt_dict_hash_ext(((void*)&key), sizeof(uintptr_t));
+ xbt_dictelm_t current;
+
+ xbt_assert(dict);
+
+ current = dict->table[hash_code & dict->table_size];
+ while (current != NULL &&
+ (hash_code != current->hash_code || sizeof(uintptr_t) != current->key_len
+ || (((uintptr_t)key) != ((uintptr_t)current->key)) )) {
+ current = current->next;
+ }
+
+ if (current == NULL)
+ return 0;
+
+ return (uintptr_t)(current->content);