summaryrefslogtreecommitdiff
path: root/src/test/test-prioq.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/test/test-prioq.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/test/test-prioq.c')
-rw-r--r--src/test/test-prioq.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/test/test-prioq.c b/src/test/test-prioq.c
index cdb1e4ad52..dfedc9b8dc 100644
--- a/src/test/test-prioq.c
+++ b/src/test/test-prioq.c
@@ -98,6 +98,11 @@ static unsigned long test_hash(const void *a, const uint8_t hash_key[HASH_KEY_SI
return (unsigned long) u;
}
+static const struct hash_ops test_hash_ops = {
+ .hash = test_hash,
+ .compare = test_compare
+};
+
static void test_struct(void) {
Prioq *q;
Set *s;
@@ -109,7 +114,7 @@ static void test_struct(void) {
q = prioq_new(test_compare);
assert_se(q);
- s = set_new(test_hash, test_compare);
+ s = set_new(&test_hash_ops);
assert_se(s);
for (i = 0; i < SET_SIZE; i++) {