summaryrefslogtreecommitdiff
path: root/src/login
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/login
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/login')
-rw-r--r--src/login/logind-acl.c2
-rw-r--r--src/login/logind-session.c2
-rw-r--r--src/login/logind.c18
3 files changed, 11 insertions, 11 deletions
diff --git a/src/login/logind-acl.c b/src/login/logind-acl.c
index b76e16d906..f7c6f3a4ef 100644
--- a/src/login/logind-acl.c
+++ b/src/login/logind-acl.c
@@ -190,7 +190,7 @@ int devnode_acl_all(struct udev *udev,
assert(udev);
- nodes = set_new(string_hash_func, string_compare_func);
+ nodes = set_new(&string_hash_ops);
if (!nodes)
return -ENOMEM;
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
index 10a43a4a30..eeb58c9031 100644
--- a/src/login/logind-session.c
+++ b/src/login/logind-session.c
@@ -61,7 +61,7 @@ Session* session_new(Manager *m, const char *id) {
return NULL;
}
- s->devices = hashmap_new(devt_hash_func, devt_compare_func);
+ s->devices = hashmap_new(&devt_hash_ops);
if (!s->devices) {
free(s->state_file);
free(s);
diff --git a/src/login/logind.c b/src/login/logind.c
index 1f94a97bd0..f1b6a86298 100644
--- a/src/login/logind.c
+++ b/src/login/logind.c
@@ -64,17 +64,17 @@ Manager *manager_new(void) {
m->runtime_dir_size = PAGE_ALIGN((size_t) (physical_memory() / 10)); /* 10% */
- m->devices = hashmap_new(string_hash_func, string_compare_func);
- m->seats = hashmap_new(string_hash_func, string_compare_func);
- m->sessions = hashmap_new(string_hash_func, string_compare_func);
- m->users = hashmap_new(trivial_hash_func, trivial_compare_func);
- m->inhibitors = hashmap_new(string_hash_func, string_compare_func);
- m->buttons = hashmap_new(string_hash_func, string_compare_func);
+ m->devices = hashmap_new(&string_hash_ops);
+ m->seats = hashmap_new(&string_hash_ops);
+ m->sessions = hashmap_new(&string_hash_ops);
+ m->users = hashmap_new(NULL);
+ m->inhibitors = hashmap_new(&string_hash_ops);
+ m->buttons = hashmap_new(&string_hash_ops);
- m->user_units = hashmap_new(string_hash_func, string_compare_func);
- m->session_units = hashmap_new(string_hash_func, string_compare_func);
+ m->user_units = hashmap_new(&string_hash_ops);
+ m->session_units = hashmap_new(&string_hash_ops);
- m->busnames = set_new(string_hash_func, string_compare_func);
+ m->busnames = set_new(&string_hash_ops);
if (!m->devices || !m->seats || !m->sessions || !m->users || !m->inhibitors || !m->buttons || !m->busnames ||
!m->user_units || !m->session_units)