free(h);
}
-HashmapBase* _hashmap_free(HashmapBase *h, free_func_t default_free_key, free_func_t default_free_value) {
+HashmapBase* _hashmap_free(HashmapBase *h) {
if (h) {
- _hashmap_clear(h, default_free_key, default_free_value);
+ _hashmap_clear(h);
hashmap_free_no_clear(h);
}
return NULL;
}
-void _hashmap_clear(HashmapBase *h, free_func_t default_free_key, free_func_t default_free_value) {
- free_func_t free_key, free_value;
+void _hashmap_clear(HashmapBase *h) {
if (!h)
return;
- free_key = h->hash_ops->free_key ?: default_free_key;
- free_value = h->hash_ops->free_value ?: default_free_value;
-
- if (free_key || free_value) {
+ if (h->hash_ops->free_key || h->hash_ops->free_value) {
/* If destructor calls are defined, let's destroy things defensively: let's take the item out of the
* hash table, and only then call the destructor functions. If these destructors then try to unregister
v = _hashmap_first_key_and_value(h, true, &k);
- if (free_key)
- free_key(k);
+ if (h->hash_ops->free_key)
+ h->hash_ops->free_key(k);
- if (free_value)
- free_value(v);
+ if (h->hash_ops->free_value)
+ h->hash_ops->free_value(v);
}
}
}
if (r < 0)
- return _hashmap_free(copy, NULL, NULL);
+ return _hashmap_free(copy);
return copy;
}
#define ordered_hashmap_free_and_replace(a, b) \
free_and_replace_full(a, b, ordered_hashmap_free)
-HashmapBase* _hashmap_free(HashmapBase *h, free_func_t default_free_key, free_func_t default_free_value);
+HashmapBase* _hashmap_free(HashmapBase *h);
static inline Hashmap* hashmap_free(Hashmap *h) {
- return (void*) _hashmap_free(HASHMAP_BASE(h), NULL, NULL);
+ return (void*) _hashmap_free(HASHMAP_BASE(h));
}
static inline OrderedHashmap* ordered_hashmap_free(OrderedHashmap *h) {
- return (void*) _hashmap_free(HASHMAP_BASE(h), NULL, NULL);
+ return (void*) _hashmap_free(HASHMAP_BASE(h));
}
IteratedCache* iterated_cache_free(IteratedCache *cache);
return _hashmap_iterate(HASHMAP_BASE(h), i, value, key);
}
-void _hashmap_clear(HashmapBase *h, free_func_t default_free_key, free_func_t default_free_value);
+void _hashmap_clear(HashmapBase *h);
static inline void hashmap_clear(Hashmap *h) {
- _hashmap_clear(HASHMAP_BASE(h), NULL, NULL);
+ _hashmap_clear(HASHMAP_BASE(h));
}
static inline void ordered_hashmap_clear(OrderedHashmap *h) {
- _hashmap_clear(HASHMAP_BASE(h), NULL, NULL);
+ _hashmap_clear(HASHMAP_BASE(h));
}
/*
#define set_new(ops) _set_new(ops HASHMAP_DEBUG_SRC_ARGS)
static inline Set* set_free(Set *s) {
- return (Set*) _hashmap_free(HASHMAP_BASE(s), NULL, NULL);
+ return (Set*) _hashmap_free(HASHMAP_BASE(s));
}
#define set_copy(s) ((Set*) _hashmap_copy(HASHMAP_BASE(s) HASHMAP_DEBUG_SRC_ARGS))
}
static inline void set_clear(Set *s) {
- _hashmap_clear(HASHMAP_BASE(s), NULL, NULL);
+ _hashmap_clear(HASHMAP_BASE(s));
}
static inline void *set_steal_first(Set *s) {