summaryrefslogtreecommitdiff
path: root/src/shared/set.c
diff options
context:
space:
mode:
authorMichal Schmidt <mschmidt@redhat.com>2014-08-13 01:00:18 +0200
committerMichal Schmidt <mschmidt@redhat.com>2014-09-15 16:08:50 +0200
commitd5099efc47d4e6ac60816b5381a5f607ab03f06e (patch)
tree661308aae8a0885e90da25874e7df3e795532356 /src/shared/set.c
parentf44541bc934c6e2b02155559e9eeb17a13a09558 (diff)
hashmap: introduce hash_ops to make struct Hashmap smaller
It is redundant to store 'hash' and 'compare' function pointers in struct Hashmap separately. The functions always comprise a pair. Store a single pointer to struct hash_ops instead. systemd keeps hundreds of hashmaps, so this saves a little bit of memory.
Diffstat (limited to 'src/shared/set.c')
-rw-r--r--src/shared/set.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/shared/set.c b/src/shared/set.c
index 02ea831593..d4ffe056d5 100644
--- a/src/shared/set.c
+++ b/src/shared/set.c
@@ -30,8 +30,8 @@
/* For now this is not much more than a wrapper around a hashmap */
-Set *set_new(hash_func_t hash_func, compare_func_t compare_func) {
- return MAKE_SET(hashmap_new(hash_func, compare_func));
+Set *set_new(const struct hash_ops *hash_ops) {
+ return MAKE_SET(hashmap_new(hash_ops));
}
void set_free(Set* s) {
@@ -42,8 +42,8 @@ void set_free_free(Set *s) {
hashmap_free_free(MAKE_HASHMAP(s));
}
-int set_ensure_allocated(Set **s, hash_func_t hash_func, compare_func_t compare_func) {
- return hashmap_ensure_allocated((Hashmap**) s, hash_func, compare_func);
+int set_ensure_allocated(Set **s, const struct hash_ops *hash_ops) {
+ return hashmap_ensure_allocated((Hashmap**) s, hash_ops);
}
int set_put(Set *s, void *value) {