summaryrefslogtreecommitdiff
path: root/src/libsystemd-network
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/libsystemd-network
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/libsystemd-network')
-rw-r--r--src/libsystemd-network/sd-dhcp-server.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/libsystemd-network/sd-dhcp-server.c b/src/libsystemd-network/sd-dhcp-server.c
index ab683228b4..a6d6178e72 100644
--- a/src/libsystemd-network/sd-dhcp-server.c
+++ b/src/libsystemd-network/sd-dhcp-server.c
@@ -109,6 +109,11 @@ int client_id_compare_func(const void *_a, const void *_b) {
return memcmp(a->data, b->data, a->length);
}
+static const struct hash_ops client_id_hash_ops = {
+ .hash = client_id_hash_func,
+ .compare = client_id_compare_func
+};
+
static void dhcp_lease_free(DHCPLease *lease) {
if (!lease)
return;
@@ -158,8 +163,7 @@ int sd_dhcp_server_new(sd_dhcp_server **ret, int ifindex) {
server->address = htobe32(INADDR_ANY);
server->netmask = htobe32(INADDR_ANY);
server->index = ifindex;
- server->leases_by_client_id = hashmap_new(client_id_hash_func,
- client_id_compare_func);
+ server->leases_by_client_id = hashmap_new(&client_id_hash_ops);
*ret = server;
server = NULL;