|
|
17aa40 |
From 3bee193141bdf3106732a2c925ffaf5ce48f0ecb Mon Sep 17 00:00:00 2001
|
|
|
17aa40 |
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
|
|
17aa40 |
Date: Tue, 27 Nov 2018 22:25:40 +0900
|
|
|
17aa40 |
Subject: [PATCH] hash-func: add destructors for key and value
|
|
|
17aa40 |
|
|
|
17aa40 |
If they are set, then they are called in hashmap_clear() or
|
|
|
17aa40 |
hashmap_free().
|
|
|
17aa40 |
|
|
|
17aa40 |
(cherry picked from commit 59a5cda7b904cd7ef9853bda15b498bbc0577524)
|
|
|
17aa40 |
|
|
|
17aa40 |
Resolves: #2037807
|
|
|
17aa40 |
---
|
|
|
17aa40 |
src/basic/hash-funcs.h | 54 ++++++++++++++++++++++++++---
|
|
|
17aa40 |
src/basic/hashmap.c | 76 +++++++++++------------------------------
|
|
|
17aa40 |
src/basic/hashmap.h | 50 ++++++++++++++++++---------
|
|
|
17aa40 |
src/basic/ordered-set.h | 6 ++--
|
|
|
17aa40 |
src/basic/set.h | 10 +++---
|
|
|
17aa40 |
5 files changed, 109 insertions(+), 87 deletions(-)
|
|
|
17aa40 |
|
|
|
17aa40 |
diff --git a/src/basic/hash-funcs.h b/src/basic/hash-funcs.h
|
|
|
17aa40 |
index 2ff687e5f9..2d3125d0f9 100644
|
|
|
17aa40 |
--- a/src/basic/hash-funcs.h
|
|
|
17aa40 |
+++ b/src/basic/hash-funcs.h
|
|
|
17aa40 |
@@ -1,7 +1,7 @@
|
|
|
17aa40 |
/* SPDX-License-Identifier: LGPL-2.1+ */
|
|
|
17aa40 |
#pragma once
|
|
|
17aa40 |
|
|
|
17aa40 |
-
|
|
|
17aa40 |
+#include "alloc-util.h"
|
|
|
17aa40 |
#include "macro.h"
|
|
|
17aa40 |
#include "siphash24.h"
|
|
|
17aa40 |
|
|
|
17aa40 |
@@ -11,21 +11,67 @@ typedef int (*compare_func_t)(const void *a, const void *b);
|
|
|
17aa40 |
struct hash_ops {
|
|
|
17aa40 |
hash_func_t hash;
|
|
|
17aa40 |
compare_func_t compare;
|
|
|
17aa40 |
+ free_func_t free_key;
|
|
|
17aa40 |
+ free_func_t free_value;
|
|
|
17aa40 |
};
|
|
|
17aa40 |
|
|
|
17aa40 |
-#define _DEFINE_HASH_OPS(uq, name, type, hash_func, compare_func, scope) \
|
|
|
17aa40 |
+#define _DEFINE_HASH_OPS(uq, name, type, hash_func, compare_func, free_key_func, free_value_func, scope) \
|
|
|
17aa40 |
_unused_ static void (* UNIQ_T(static_hash_wrapper, uq))(const type *, struct siphash *) = hash_func; \
|
|
|
17aa40 |
_unused_ static int (* UNIQ_T(static_compare_wrapper, uq))(const type *, const type *) = compare_func; \
|
|
|
17aa40 |
scope const struct hash_ops name = { \
|
|
|
17aa40 |
.hash = (hash_func_t) hash_func, \
|
|
|
17aa40 |
.compare = (compare_func_t) compare_func, \
|
|
|
17aa40 |
+ .free_key = free_key_func, \
|
|
|
17aa40 |
+ .free_value = free_value_func, \
|
|
|
17aa40 |
+ }
|
|
|
17aa40 |
+
|
|
|
17aa40 |
+#define _DEFINE_FREE_FUNC(uq, type, wrapper_name, func) \
|
|
|
17aa40 |
+ /* Type-safe free function */ \
|
|
|
17aa40 |
+ static void UNIQ_T(wrapper_name, uq)(void *a) { \
|
|
|
17aa40 |
+ type *_a = a; \
|
|
|
17aa40 |
+ func(_a); \
|
|
|
17aa40 |
}
|
|
|
17aa40 |
|
|
|
17aa40 |
+#define _DEFINE_HASH_OPS_WITH_KEY_DESTRUCTOR(uq, name, type, hash_func, compare_func, free_func, scope) \
|
|
|
17aa40 |
+ _DEFINE_FREE_FUNC(uq, type, static_free_wrapper, free_func); \
|
|
|
17aa40 |
+ _DEFINE_HASH_OPS(uq, name, type, hash_func, compare_func, \
|
|
|
17aa40 |
+ UNIQ_T(static_free_wrapper, uq), NULL, scope)
|
|
|
17aa40 |
+
|
|
|
17aa40 |
+#define _DEFINE_HASH_OPS_WITH_VALUE_DESTRUCTOR(uq, name, type, hash_func, compare_func, type_value, free_func, scope) \
|
|
|
17aa40 |
+ _DEFINE_FREE_FUNC(uq, type_value, static_free_wrapper, free_func); \
|
|
|
17aa40 |
+ _DEFINE_HASH_OPS(uq, name, type, hash_func, compare_func, \
|
|
|
17aa40 |
+ NULL, UNIQ_T(static_free_wrapper, uq), scope)
|
|
|
17aa40 |
+
|
|
|
17aa40 |
+#define _DEFINE_HASH_OPS_FULL(uq, name, type, hash_func, compare_func, free_key_func, type_value, free_value_func, scope) \
|
|
|
17aa40 |
+ _DEFINE_FREE_FUNC(uq, type, static_free_key_wrapper, free_key_func); \
|
|
|
17aa40 |
+ _DEFINE_FREE_FUNC(uq, type_value, static_free_value_wrapper, free_value_func); \
|
|
|
17aa40 |
+ _DEFINE_HASH_OPS(uq, name, type, hash_func, compare_func, \
|
|
|
17aa40 |
+ UNIQ_T(static_free_key_wrapper, uq), \
|
|
|
17aa40 |
+ UNIQ_T(static_free_value_wrapper, uq), scope)
|
|
|
17aa40 |
+
|
|
|
17aa40 |
#define DEFINE_HASH_OPS(name, type, hash_func, compare_func) \
|
|
|
17aa40 |
- _DEFINE_HASH_OPS(UNIQ, name, type, hash_func, compare_func,)
|
|
|
17aa40 |
+ _DEFINE_HASH_OPS(UNIQ, name, type, hash_func, compare_func, NULL, NULL,)
|
|
|
17aa40 |
|
|
|
17aa40 |
#define DEFINE_PRIVATE_HASH_OPS(name, type, hash_func, compare_func) \
|
|
|
17aa40 |
- _DEFINE_HASH_OPS(UNIQ, name, type, hash_func, compare_func, static)
|
|
|
17aa40 |
+ _DEFINE_HASH_OPS(UNIQ, name, type, hash_func, compare_func, NULL, NULL, static)
|
|
|
17aa40 |
+
|
|
|
17aa40 |
+#define DEFINE_HASH_OPS_WITH_KEY_DESTRUCTOR(name, type, hash_func, compare_func, free_func) \
|
|
|
17aa40 |
+ _DEFINE_HASH_OPS_WITH_KEY_DESTRUCTOR(UNIQ, name, type, hash_func, compare_func, free_func,)
|
|
|
17aa40 |
+
|
|
|
17aa40 |
+#define DEFINE_PRIVATE_HASH_OPS_WITH_KEY_DESTRUCTOR(name, type, hash_func, compare_func, free_func) \
|
|
|
17aa40 |
+ _DEFINE_HASH_OPS_WITH_KEY_DESTRUCTOR(UNIQ, name, type, hash_func, compare_func, free_func, static)
|
|
|
17aa40 |
+
|
|
|
17aa40 |
+#define DEFINE_HASH_OPS_WITH_VALUE_DESTRUCTOR(name, type, hash_func, compare_func, value_type, free_func) \
|
|
|
17aa40 |
+ _DEFINE_HASH_OPS_WITH_VALUE_DESTRUCTOR(UNIQ, name, type, hash_func, compare_func, value_type, free_func,)
|
|
|
17aa40 |
+
|
|
|
17aa40 |
+#define DEFINE_PRIVATE_HASH_OPS_WITH_VALUE_DESTRUCTOR(name, type, hash_func, compare_func, value_type, free_func) \
|
|
|
17aa40 |
+ _DEFINE_HASH_OPS_WITH_VALUE_DESTRUCTOR(UNIQ, name, type, hash_func, compare_func, value_type, free_func, static)
|
|
|
17aa40 |
+
|
|
|
17aa40 |
+#define DEFINE_HASH_OPS_FULL(name, type, hash_func, compare_func, free_key_func, value_type, free_value_func) \
|
|
|
17aa40 |
+ _DEFINE_HASH_OPS_FULL(UNIQ, name, type, hash_func, compare_func, free_key_func, value_type, free_value_func,)
|
|
|
17aa40 |
+
|
|
|
17aa40 |
+#define DEFINE_PRIVATE_HASH_OPS_FULL(name, type, hash_func, compare_func, free_key_func, value_type, free_value_func) \
|
|
|
17aa40 |
+ _DEFINE_HASH_OPS_FULL(UNIQ, name, type, hash_func, compare_func, free_key_func, value_type, free_value_func, static)
|
|
|
17aa40 |
|
|
|
17aa40 |
void string_hash_func(const void *p, struct siphash *state);
|
|
|
17aa40 |
int string_compare_func(const void *a, const void *b) _pure_;
|
|
|
17aa40 |
diff --git a/src/basic/hashmap.c b/src/basic/hashmap.c
|
|
|
17aa40 |
index 69a7d70b04..7c508086f0 100644
|
|
|
17aa40 |
--- a/src/basic/hashmap.c
|
|
|
17aa40 |
+++ b/src/basic/hashmap.c
|
|
|
17aa40 |
@@ -863,47 +863,38 @@ static void hashmap_free_no_clear(HashmapBase *h) {
|
|
|
17aa40 |
free(h);
|
|
|
17aa40 |
}
|
|
|
17aa40 |
|
|
|
17aa40 |
-HashmapBase *internal_hashmap_free(HashmapBase *h) {
|
|
|
17aa40 |
-
|
|
|
17aa40 |
- /* Free the hashmap, but nothing in it */
|
|
|
17aa40 |
-
|
|
|
17aa40 |
+HashmapBase *internal_hashmap_free(HashmapBase *h, free_func_t default_free_key, free_func_t default_free_value) {
|
|
|
17aa40 |
if (h) {
|
|
|
17aa40 |
- internal_hashmap_clear(h);
|
|
|
17aa40 |
+ internal_hashmap_clear(h, default_free_key, default_free_value);
|
|
|
17aa40 |
hashmap_free_no_clear(h);
|
|
|
17aa40 |
}
|
|
|
17aa40 |
|
|
|
17aa40 |
return NULL;
|
|
|
17aa40 |
}
|
|
|
17aa40 |
|
|
|
17aa40 |
-HashmapBase *internal_hashmap_free_free(HashmapBase *h) {
|
|
|
17aa40 |
+void internal_hashmap_clear(HashmapBase *h, free_func_t default_free_key, free_func_t default_free_value) {
|
|
|
17aa40 |
+ free_func_t free_key, free_value;
|
|
|
17aa40 |
+ if (!h)
|
|
|
17aa40 |
+ return;
|
|
|
17aa40 |
|
|
|
17aa40 |
- /* Free the hashmap and all data objects in it, but not the
|
|
|
17aa40 |
- * keys */
|
|
|
17aa40 |
+ free_key = h->hash_ops->free_key ?: default_free_key;
|
|
|
17aa40 |
+ free_value = h->hash_ops->free_value ?: default_free_value;
|
|
|
17aa40 |
|
|
|
17aa40 |
- if (h) {
|
|
|
17aa40 |
- internal_hashmap_clear_free(h);
|
|
|
17aa40 |
- hashmap_free_no_clear(h);
|
|
|
17aa40 |
- }
|
|
|
17aa40 |
-
|
|
|
17aa40 |
- return NULL;
|
|
|
17aa40 |
-}
|
|
|
17aa40 |
+ if (free_key || free_value) {
|
|
|
17aa40 |
+ unsigned idx;
|
|
|
17aa40 |
|
|
|
17aa40 |
-Hashmap *hashmap_free_free_free(Hashmap *h) {
|
|
|
17aa40 |
+ for (idx = skip_free_buckets(h, 0); idx != IDX_NIL;
|
|
|
17aa40 |
+ idx = skip_free_buckets(h, idx + 1)) {
|
|
|
17aa40 |
+ struct hashmap_base_entry *e = bucket_at(h, idx);
|
|
|
17aa40 |
|
|
|
17aa40 |
- /* Free the hashmap and all data and key objects in it */
|
|
|
17aa40 |
+ if (free_key)
|
|
|
17aa40 |
+ free_key((void *) e->key);
|
|
|
17aa40 |
|
|
|
17aa40 |
- if (h) {
|
|
|
17aa40 |
- hashmap_clear_free_free(h);
|
|
|
17aa40 |
- hashmap_free_no_clear(HASHMAP_BASE(h));
|
|
|
17aa40 |
+ if (free_value)
|
|
|
17aa40 |
+ free_value(entry_value(h, e));
|
|
|
17aa40 |
+ }
|
|
|
17aa40 |
}
|
|
|
17aa40 |
|
|
|
17aa40 |
- return NULL;
|
|
|
17aa40 |
-}
|
|
|
17aa40 |
-
|
|
|
17aa40 |
-void internal_hashmap_clear(HashmapBase *h) {
|
|
|
17aa40 |
- if (!h)
|
|
|
17aa40 |
- return;
|
|
|
17aa40 |
-
|
|
|
17aa40 |
if (h->has_indirect) {
|
|
|
17aa40 |
free(h->indirect.storage);
|
|
|
17aa40 |
h->has_indirect = false;
|
|
|
17aa40 |
@@ -920,35 +911,6 @@ void internal_hashmap_clear(HashmapBase *h) {
|
|
|
17aa40 |
base_set_dirty(h);
|
|
|
17aa40 |
}
|
|
|
17aa40 |
|
|
|
17aa40 |
-void internal_hashmap_clear_free(HashmapBase *h) {
|
|
|
17aa40 |
- unsigned idx;
|
|
|
17aa40 |
-
|
|
|
17aa40 |
- if (!h)
|
|
|
17aa40 |
- return;
|
|
|
17aa40 |
-
|
|
|
17aa40 |
- for (idx = skip_free_buckets(h, 0); idx != IDX_NIL;
|
|
|
17aa40 |
- idx = skip_free_buckets(h, idx + 1))
|
|
|
17aa40 |
- free(entry_value(h, bucket_at(h, idx)));
|
|
|
17aa40 |
-
|
|
|
17aa40 |
- internal_hashmap_clear(h);
|
|
|
17aa40 |
-}
|
|
|
17aa40 |
-
|
|
|
17aa40 |
-void hashmap_clear_free_free(Hashmap *h) {
|
|
|
17aa40 |
- unsigned idx;
|
|
|
17aa40 |
-
|
|
|
17aa40 |
- if (!h)
|
|
|
17aa40 |
- return;
|
|
|
17aa40 |
-
|
|
|
17aa40 |
- for (idx = skip_free_buckets(HASHMAP_BASE(h), 0); idx != IDX_NIL;
|
|
|
17aa40 |
- idx = skip_free_buckets(HASHMAP_BASE(h), idx + 1)) {
|
|
|
17aa40 |
- struct plain_hashmap_entry *e = plain_bucket_at(h, idx);
|
|
|
17aa40 |
- free((void*)e->b.key);
|
|
|
17aa40 |
- free(e->value);
|
|
|
17aa40 |
- }
|
|
|
17aa40 |
-
|
|
|
17aa40 |
- internal_hashmap_clear(HASHMAP_BASE(h));
|
|
|
17aa40 |
-}
|
|
|
17aa40 |
-
|
|
|
17aa40 |
static int resize_buckets(HashmapBase *h, unsigned entries_add);
|
|
|
17aa40 |
|
|
|
17aa40 |
/*
|
|
|
17aa40 |
@@ -1771,7 +1733,7 @@ HashmapBase *internal_hashmap_copy(HashmapBase *h) {
|
|
|
17aa40 |
}
|
|
|
17aa40 |
|
|
|
17aa40 |
if (r < 0) {
|
|
|
17aa40 |
- internal_hashmap_free(copy);
|
|
|
17aa40 |
+ internal_hashmap_free(copy, false, false);
|
|
|
17aa40 |
return NULL;
|
|
|
17aa40 |
}
|
|
|
17aa40 |
|
|
|
17aa40 |
diff --git a/src/basic/hashmap.h b/src/basic/hashmap.h
|
|
|
17aa40 |
index 5c70c102d7..9e4772b497 100644
|
|
|
17aa40 |
--- a/src/basic/hashmap.h
|
|
|
17aa40 |
+++ b/src/basic/hashmap.h
|
|
|
17aa40 |
@@ -23,6 +23,8 @@
|
|
|
17aa40 |
|
|
|
17aa40 |
#define HASH_KEY_SIZE 16
|
|
|
17aa40 |
|
|
|
17aa40 |
+typedef void* (*hashmap_destroy_t)(void *p);
|
|
|
17aa40 |
+
|
|
|
17aa40 |
/* The base type for all hashmap and set types. Many functions in the
|
|
|
17aa40 |
* implementation take (HashmapBase*) parameters and are run-time polymorphic,
|
|
|
17aa40 |
* though the API is not meant to be polymorphic (do not call functions
|
|
|
17aa40 |
@@ -88,25 +90,33 @@ OrderedHashmap *internal_ordered_hashmap_new(const struct hash_ops *hash_ops HA
|
|
|
17aa40 |
#define hashmap_new(ops) internal_hashmap_new(ops HASHMAP_DEBUG_SRC_ARGS)
|
|
|
17aa40 |
#define ordered_hashmap_new(ops) internal_ordered_hashmap_new(ops HASHMAP_DEBUG_SRC_ARGS)
|
|
|
17aa40 |
|
|
|
17aa40 |
-HashmapBase *internal_hashmap_free(HashmapBase *h);
|
|
|
17aa40 |
+HashmapBase *internal_hashmap_free(HashmapBase *h, free_func_t default_free_key, free_func_t default_free_value);
|
|
|
17aa40 |
static inline Hashmap *hashmap_free(Hashmap *h) {
|
|
|
17aa40 |
- return (void*)internal_hashmap_free(HASHMAP_BASE(h));
|
|
|
17aa40 |
+ return (void*) internal_hashmap_free(HASHMAP_BASE(h), NULL, NULL);
|
|
|
17aa40 |
}
|
|
|
17aa40 |
static inline OrderedHashmap *ordered_hashmap_free(OrderedHashmap *h) {
|
|
|
17aa40 |
- return (void*)internal_hashmap_free(HASHMAP_BASE(h));
|
|
|
17aa40 |
+ return (void*) internal_hashmap_free(HASHMAP_BASE(h), NULL, NULL);
|
|
|
17aa40 |
}
|
|
|
17aa40 |
|
|
|
17aa40 |
-HashmapBase *internal_hashmap_free_free(HashmapBase *h);
|
|
|
17aa40 |
static inline Hashmap *hashmap_free_free(Hashmap *h) {
|
|
|
17aa40 |
- return (void*)internal_hashmap_free_free(HASHMAP_BASE(h));
|
|
|
17aa40 |
+ return (void*) internal_hashmap_free(HASHMAP_BASE(h), NULL, free);
|
|
|
17aa40 |
}
|
|
|
17aa40 |
static inline OrderedHashmap *ordered_hashmap_free_free(OrderedHashmap *h) {
|
|
|
17aa40 |
- return (void*)internal_hashmap_free_free(HASHMAP_BASE(h));
|
|
|
17aa40 |
+ return (void*) internal_hashmap_free(HASHMAP_BASE(h), NULL, free);
|
|
|
17aa40 |
}
|
|
|
17aa40 |
|
|
|
17aa40 |
-Hashmap *hashmap_free_free_free(Hashmap *h);
|
|
|
17aa40 |
+static inline Hashmap *hashmap_free_free_key(Hashmap *h) {
|
|
|
17aa40 |
+ return (void*) internal_hashmap_free(HASHMAP_BASE(h), free, NULL);
|
|
|
17aa40 |
+}
|
|
|
17aa40 |
+static inline OrderedHashmap *ordered_hashmap_free_free_key(OrderedHashmap *h) {
|
|
|
17aa40 |
+ return (void*) internal_hashmap_free(HASHMAP_BASE(h), free, NULL);
|
|
|
17aa40 |
+}
|
|
|
17aa40 |
+
|
|
|
17aa40 |
+static inline Hashmap *hashmap_free_free_free(Hashmap *h) {
|
|
|
17aa40 |
+ return (void*) internal_hashmap_free(HASHMAP_BASE(h), free, free);
|
|
|
17aa40 |
+}
|
|
|
17aa40 |
static inline OrderedHashmap *ordered_hashmap_free_free_free(OrderedHashmap *h) {
|
|
|
17aa40 |
- return (void*)hashmap_free_free_free(PLAIN_HASHMAP(h));
|
|
|
17aa40 |
+ return (void*) internal_hashmap_free(HASHMAP_BASE(h), free, free);
|
|
|
17aa40 |
}
|
|
|
17aa40 |
|
|
|
17aa40 |
IteratedCache *iterated_cache_free(IteratedCache *cache);
|
|
|
17aa40 |
@@ -259,25 +269,33 @@ static inline bool ordered_hashmap_iterate(OrderedHashmap *h, Iterator *i, void
|
|
|
17aa40 |
return internal_hashmap_iterate(HASHMAP_BASE(h), i, value, key);
|
|
|
17aa40 |
}
|
|
|
17aa40 |
|
|
|
17aa40 |
-void internal_hashmap_clear(HashmapBase *h);
|
|
|
17aa40 |
+void internal_hashmap_clear(HashmapBase *h, free_func_t default_free_key, free_func_t default_free_value);
|
|
|
17aa40 |
static inline void hashmap_clear(Hashmap *h) {
|
|
|
17aa40 |
- internal_hashmap_clear(HASHMAP_BASE(h));
|
|
|
17aa40 |
+ internal_hashmap_clear(HASHMAP_BASE(h), NULL, NULL);
|
|
|
17aa40 |
}
|
|
|
17aa40 |
static inline void ordered_hashmap_clear(OrderedHashmap *h) {
|
|
|
17aa40 |
- internal_hashmap_clear(HASHMAP_BASE(h));
|
|
|
17aa40 |
+ internal_hashmap_clear(HASHMAP_BASE(h), NULL, NULL);
|
|
|
17aa40 |
}
|
|
|
17aa40 |
|
|
|
17aa40 |
-void internal_hashmap_clear_free(HashmapBase *h);
|
|
|
17aa40 |
static inline void hashmap_clear_free(Hashmap *h) {
|
|
|
17aa40 |
- internal_hashmap_clear_free(HASHMAP_BASE(h));
|
|
|
17aa40 |
+ internal_hashmap_clear(HASHMAP_BASE(h), NULL, free);
|
|
|
17aa40 |
}
|
|
|
17aa40 |
static inline void ordered_hashmap_clear_free(OrderedHashmap *h) {
|
|
|
17aa40 |
- internal_hashmap_clear_free(HASHMAP_BASE(h));
|
|
|
17aa40 |
+ internal_hashmap_clear(HASHMAP_BASE(h), NULL, free);
|
|
|
17aa40 |
}
|
|
|
17aa40 |
|
|
|
17aa40 |
-void hashmap_clear_free_free(Hashmap *h);
|
|
|
17aa40 |
+static inline void hashmap_clear_free_key(Hashmap *h) {
|
|
|
17aa40 |
+ internal_hashmap_clear(HASHMAP_BASE(h), free, NULL);
|
|
|
17aa40 |
+}
|
|
|
17aa40 |
+static inline void ordered_hashmap_clear_free_key(OrderedHashmap *h) {
|
|
|
17aa40 |
+ internal_hashmap_clear(HASHMAP_BASE(h), free, NULL);
|
|
|
17aa40 |
+}
|
|
|
17aa40 |
+
|
|
|
17aa40 |
+static inline void hashmap_clear_free_free(Hashmap *h) {
|
|
|
17aa40 |
+ internal_hashmap_clear(HASHMAP_BASE(h), free, free);
|
|
|
17aa40 |
+}
|
|
|
17aa40 |
static inline void ordered_hashmap_clear_free_free(OrderedHashmap *h) {
|
|
|
17aa40 |
- hashmap_clear_free_free(PLAIN_HASHMAP(h));
|
|
|
17aa40 |
+ internal_hashmap_clear(HASHMAP_BASE(h), free, free);
|
|
|
17aa40 |
}
|
|
|
17aa40 |
|
|
|
17aa40 |
/*
|
|
|
17aa40 |
diff --git a/src/basic/ordered-set.h b/src/basic/ordered-set.h
|
|
|
17aa40 |
index e7c054d8e4..7cbb71819b 100644
|
|
|
17aa40 |
--- a/src/basic/ordered-set.h
|
|
|
17aa40 |
+++ b/src/basic/ordered-set.h
|
|
|
17aa40 |
@@ -21,13 +21,11 @@ static inline int ordered_set_ensure_allocated(OrderedSet **s, const struct hash
|
|
|
17aa40 |
}
|
|
|
17aa40 |
|
|
|
17aa40 |
static inline OrderedSet* ordered_set_free(OrderedSet *s) {
|
|
|
17aa40 |
- ordered_hashmap_free((OrderedHashmap*) s);
|
|
|
17aa40 |
- return NULL;
|
|
|
17aa40 |
+ return (OrderedSet*) ordered_hashmap_free((OrderedHashmap*) s);
|
|
|
17aa40 |
}
|
|
|
17aa40 |
|
|
|
17aa40 |
static inline OrderedSet* ordered_set_free_free(OrderedSet *s) {
|
|
|
17aa40 |
- ordered_hashmap_free_free((OrderedHashmap*) s);
|
|
|
17aa40 |
- return NULL;
|
|
|
17aa40 |
+ return (OrderedSet*) ordered_hashmap_free_free((OrderedHashmap*) s);
|
|
|
17aa40 |
}
|
|
|
17aa40 |
|
|
|
17aa40 |
static inline int ordered_set_put(OrderedSet *s, void *p) {
|
|
|
17aa40 |
diff --git a/src/basic/set.h b/src/basic/set.h
|
|
|
17aa40 |
index 664713810d..8e12670a6e 100644
|
|
|
17aa40 |
--- a/src/basic/set.h
|
|
|
17aa40 |
+++ b/src/basic/set.h
|
|
|
17aa40 |
@@ -9,13 +9,11 @@ Set *internal_set_new(const struct hash_ops *hash_ops HASHMAP_DEBUG_PARAMS);
|
|
|
17aa40 |
#define set_new(ops) internal_set_new(ops HASHMAP_DEBUG_SRC_ARGS)
|
|
|
17aa40 |
|
|
|
17aa40 |
static inline Set *set_free(Set *s) {
|
|
|
17aa40 |
- internal_hashmap_free(HASHMAP_BASE(s));
|
|
|
17aa40 |
- return NULL;
|
|
|
17aa40 |
+ return (Set*) internal_hashmap_free(HASHMAP_BASE(s), NULL, NULL);
|
|
|
17aa40 |
}
|
|
|
17aa40 |
|
|
|
17aa40 |
static inline Set *set_free_free(Set *s) {
|
|
|
17aa40 |
- internal_hashmap_free_free(HASHMAP_BASE(s));
|
|
|
17aa40 |
- return NULL;
|
|
|
17aa40 |
+ return (Set*) internal_hashmap_free(HASHMAP_BASE(s), free, NULL);
|
|
|
17aa40 |
}
|
|
|
17aa40 |
|
|
|
17aa40 |
/* no set_free_free_free */
|
|
|
17aa40 |
@@ -76,11 +74,11 @@ static inline unsigned set_buckets(Set *s) {
|
|
|
17aa40 |
bool set_iterate(Set *s, Iterator *i, void **value);
|
|
|
17aa40 |
|
|
|
17aa40 |
static inline void set_clear(Set *s) {
|
|
|
17aa40 |
- internal_hashmap_clear(HASHMAP_BASE(s));
|
|
|
17aa40 |
+ internal_hashmap_clear(HASHMAP_BASE(s), NULL, NULL);
|
|
|
17aa40 |
}
|
|
|
17aa40 |
|
|
|
17aa40 |
static inline void set_clear_free(Set *s) {
|
|
|
17aa40 |
- internal_hashmap_clear_free(HASHMAP_BASE(s));
|
|
|
17aa40 |
+ internal_hashmap_clear(HASHMAP_BASE(s), free, NULL);
|
|
|
17aa40 |
}
|
|
|
17aa40 |
|
|
|
17aa40 |
/* no set_clear_free_free */
|