tree-wide: Introduce free_and_replace_full()

Let's have all our free_and_replace() functions use a single
implementation.
This commit is contained in:
Daan De Meyer
2022-07-21 09:45:55 +09:00
committed by Yu Watanabe
parent 4a0cb5474e
commit fc4c10b28b
4 changed files with 8 additions and 22 deletions
+1 -6
View File
@@ -90,12 +90,7 @@ OrderedHashmap* _ordered_hashmap_new(const struct hash_ops *hash_ops HASHMAP_DE
#define ordered_hashmap_new(ops) _ordered_hashmap_new(ops HASHMAP_DEBUG_SRC_ARGS)
#define hashmap_free_and_replace(a, b) \
({ \
hashmap_free(a); \
(a) = (b); \
(b) = NULL; \
0; \
})
free_and_replace_full(a, b, hashmap_free)
HashmapBase* _hashmap_free(HashmapBase *h, free_func_t default_free_key, free_func_t default_free_value);
static inline Hashmap* hashmap_free(Hashmap *h) {