From d5099efc47d4e6ac60816b5381a5f607ab03f06e Mon Sep 17 00:00:00 2001 From: Michal Schmidt Date: Wed, 13 Aug 2014 01:00:18 +0200 Subject: 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. --- src/test/test-prioq.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/test/test-prioq.c') diff --git a/src/test/test-prioq.c b/src/test/test-prioq.c index cdb1e4ad5..dfedc9b8d 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++) { -- cgit v1.2.3