|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From d5099efc47d4e6ac60816b5381a5f607ab03f06e Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From: Michal Schmidt <mschmidt@redhat.com>
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Date: Wed, 13 Aug 2014 01:00:18 +0200
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Subject: [PATCH] hashmap: introduce hash_ops to make struct Hashmap smaller
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
It is redundant to store 'hash' and 'compare' function pointers in
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
struct Hashmap separately. The functions always comprise a pair.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Store a single pointer to struct hash_ops instead.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
systemd keeps hundreds of hashmaps, so this saves a little bit of
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
memory.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/analyze/analyze.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/bus-proxyd/bus-policy.c | 4 +--
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/cgtop/cgtop.c | 4 +--
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/core/automount.c | 4 +--
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/core/bus-endpoint.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/core/dbus-manager.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/core/dbus.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/core/device.c | 4 +--
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/core/killall.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/core/load-fragment.c | 10 +++----
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/core/manager.c | 14 ++++-----
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/core/mount-setup.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/core/swap.c | 4 +--
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/core/transaction.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/core/unit.c | 22 +++++++--------
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/delta/delta.c | 8 +++---
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/journal-remote/journal-remote.c | 18 ++++--------
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/journal/catalog.c | 11 ++++++--
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/journal/catalog.h | 3 +-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/journal/coredump-vacuum.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/journal/coredumpctl.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/journal/journal-file.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/journal/journalctl.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/journal/journald-server.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/journal/mmap-cache.c | 4 +--
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/journal/sd-journal.c | 8 +++---
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/journal/test-catalog.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/libsystemd-network/sd-dhcp-server.c | 8 ++++--
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/libsystemd/sd-bus/bus-match.c | 4 +--
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/libsystemd/sd-bus/bus-objects.c | 13 ++++++---
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/libsystemd/sd-bus/bus-track.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/libsystemd/sd-bus/bus-util.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/libsystemd/sd-bus/busctl.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/libsystemd/sd-bus/sd-bus.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/libsystemd/sd-event/sd-event.c | 4 +--
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/libsystemd/sd-rtnl/sd-rtnl.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/locale/localectl.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/login/logind-acl.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/login/logind-session.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/login/logind.c | 18 ++++++------
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/machine/machined.c | 6 ++--
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/network/networkd-link.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/network/networkd-manager.c | 8 +++---
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/network/networkd-network.c | 6 ++--
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/network/networkd-wait-online-link.c | 5 ++--
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/readahead/readahead-collect.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/remount-fs/remount-fs.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/resolve/resolved-dns-cache.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/resolve/resolved-dns-domain.c | 5 ++++
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/resolve/resolved-dns-domain.h | 1 +
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/resolve/resolved-dns-packet.c | 4 +--
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/resolve/resolved-dns-query.c | 4 +--
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/resolve/resolved-dns-rr.c | 9 ++++--
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/resolve/resolved-dns-rr.h | 4 +--
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/resolve/resolved-dns-scope.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/resolve/resolved-dns-server.c | 9 ++++--
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/resolve/resolved-dns-server.h | 3 +-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/resolve/resolved-dns-transaction.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/resolve/resolved-dns-zone.c | 6 ++--
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/resolve/resolved-link.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/resolve/resolved-manager.c | 4 +--
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/shared/cgroup-util.c | 6 ++--
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/shared/conf-files.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/shared/fdset.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/shared/hashmap.c | 42 +++++++++++++++++++--------
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/shared/hashmap.h | 18 ++++++++++--
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/shared/install.c | 8 +++---
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/shared/locale-util.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/shared/logs-show.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/shared/set.c | 8 +++---
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/shared/set.h | 4 +--
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/shared/util.c | 6 ++--
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/socket-proxy/socket-proxyd.c | 4 +--
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/sysctl/sysctl.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/systemctl/systemctl.c | 6 ++--
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/sysusers/sysusers.c | 22 +++++++--------
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/sysv-generator/sysv-generator.c | 8 ++----
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/test/test-hashmap.c | 50 ++++++++++++++++-----------------
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/test/test-install.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/test/test-prioq.c | 7 ++++-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/test/test-unit-file.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/tmpfiles/tmpfiles.c | 6 ++--
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
82 files changed, 278 insertions(+), 226 deletions(-)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 82f5cf3c57..5e55988063 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/analyze/analyze.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/analyze/analyze.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -907,7 +907,7 @@ static int analyze_critical_chain(sd_bus *bus, char *names[]) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (n <= 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return n;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- h = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ h = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!h)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return -ENOMEM;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/bus-proxyd/bus-policy.c b/src/bus-proxyd/bus-policy.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 06c16a7eb6..d2eace9405 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/bus-proxyd/bus-policy.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/bus-proxyd/bus-policy.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -338,7 +338,7 @@ static int file_load(Policy *p, const char *path) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_cc(sizeof(uid_t) == sizeof(uint32_t));
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&p->user_items, trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&p->user_items, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return log_oom();
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -369,7 +369,7 @@ static int file_load(Policy *p, const char *path) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_cc(sizeof(gid_t) == sizeof(uint32_t));
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&p->group_items, trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&p->group_items, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return log_oom();
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/cgtop/cgtop.c b/src/cgtop/cgtop.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 509fe4cdc8..ab8c4cfda1 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/cgtop/cgtop.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/cgtop/cgtop.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -695,8 +695,8 @@ int main(int argc, char *argv[]) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r <= 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
goto finish;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- a = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- b = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ a = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ b = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!a || !b) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
r = log_oom();
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
goto finish;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/core/automount.c b/src/core/automount.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 73a8ce17e4..f72aca2957 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/core/automount.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/core/automount.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -685,7 +685,7 @@ static int automount_deserialize_item(Unit *u, const char *key, const char *valu
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
log_debug_unit(u->id, "Failed to parse token value %s", value);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
else {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!a->tokens)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- if (!(a->tokens = set_new(trivial_hash_func, trivial_compare_func)))
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (!(a->tokens = set_new(NULL)))
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return -ENOMEM;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
r = set_put(a->tokens, UINT_TO_PTR(token));
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -762,7 +762,7 @@ static int automount_dispatch_io(sd_event_source *s, int fd, uint32_t events, vo
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
} else
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
log_debug_unit(UNIT(a)->id, "Got direct mount request on %s", a->where);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = set_ensure_allocated(&a->tokens, trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = set_ensure_allocated(&a->tokens, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
log_error_unit(UNIT(a)->id, "Failed to allocate token set.");
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
goto fail;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/core/bus-endpoint.c b/src/core/bus-endpoint.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 8d11974db4..1e8f07eb54 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/core/bus-endpoint.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/core/bus-endpoint.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -55,7 +55,7 @@ int bus_endpoint_add_policy(BusEndpoint *ep, const char *name, BusPolicyAccess a
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return 0;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
} else {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- ep->policy_hash = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ ep->policy_hash = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!ep->policy_hash)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return -ENOMEM;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 2fe9d193f6..533ce439a7 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/core/dbus-manager.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/core/dbus-manager.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1399,7 +1399,7 @@ static int method_list_unit_files(sd_bus *bus, sd_bus_message *message, void *us
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- h = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ h = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!h)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return -ENOMEM;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/core/dbus.c b/src/core/dbus.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index e7eee3c6d1..09b4a4ac6f 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/core/dbus.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/core/dbus.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -659,7 +659,7 @@ static int bus_on_connection(sd_event_source *s, int fd, uint32_t revents, void
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return 0;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = set_ensure_allocated(&m->private_buses, trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = set_ensure_allocated(&m->private_buses, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
log_oom();
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return 0;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/core/device.c b/src/core/device.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 0f28a16874..11c4261081 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/core/device.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/core/device.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -304,7 +304,7 @@ static int device_update_unit(Manager *m, struct udev_device *dev, const char *p
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
goto fail;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&m->devices_by_sysfs, string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&m->devices_by_sysfs, &string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
goto fail;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -517,7 +517,7 @@ static int device_following_set(Unit *u, Set **_set) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return 0;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- set = set_new(NULL, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ set = set_new(NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!set)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return -ENOMEM;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/core/killall.c b/src/core/killall.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 291e1f90ee..a6ff50a5a4 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/core/killall.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/core/killall.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -205,7 +205,7 @@ void broadcast_signal(int sig, bool wait_for_exit, bool send_sighup) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
_cleanup_set_free_ Set *pids = NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (wait_for_exit)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- pids = set_new(trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ pids = set_new(NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_se(sigemptyset(&mask) == 0);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_se(sigaddset(&mask, SIGCHLD) == 0);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 7cf19b93cc..0620882b4e 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/core/load-fragment.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/core/load-fragment.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -2276,7 +2276,7 @@ int config_parse_syscall_filter(
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!c->syscall_filter) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- c->syscall_filter = set_new(trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ c->syscall_filter = set_new(NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!c->syscall_filter)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return log_oom();
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -2368,7 +2368,7 @@ int config_parse_syscall_archs(
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return 0;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = set_ensure_allocated(archs, trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = set_ensure_allocated(archs, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return log_oom();
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -2474,7 +2474,7 @@ int config_parse_address_families(
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!c->address_families) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- c->address_families = set_new(trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ c->address_families = set_new(NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!c->address_families)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return log_oom();
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -3092,7 +3092,7 @@ int config_parse_set_status(
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = set_ensure_allocated(&status_set->status, NULL, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = set_ensure_allocated(&status_set->status, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return log_oom();
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -3423,7 +3423,7 @@ static int load_from_path(Unit *u, const char *path) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert(u);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert(path);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- symlink_names = set_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ symlink_names = set_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!symlink_names)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return -ENOMEM;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/core/manager.c b/src/core/manager.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 095111e8c6..0770727cde 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/core/manager.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/core/manager.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -449,27 +449,27 @@ int manager_new(SystemdRunningAs running_as, bool test_run, Manager **_m) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
goto fail;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&m->units, string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&m->units, &string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
goto fail;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&m->jobs, trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&m->jobs, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
goto fail;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&m->cgroup_unit, string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&m->cgroup_unit, &string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
goto fail;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&m->watch_bus, string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&m->watch_bus, &string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
goto fail;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = set_ensure_allocated(&m->startup_units, trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = set_ensure_allocated(&m->startup_units, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
goto fail;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = set_ensure_allocated(&m->failed_units, trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = set_ensure_allocated(&m->failed_units, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
goto fail;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -903,7 +903,7 @@ static void manager_build_unit_path_cache(Manager *m) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
set_free_free(m->unit_path_cache);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- m->unit_path_cache = set_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ m->unit_path_cache = set_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!m->unit_path_cache) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
log_error("Failed to allocate unit path cache.");
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/core/mount-setup.c b/src/core/mount-setup.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index cc2633e3bd..23a66d2e95 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/core/mount-setup.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/core/mount-setup.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -235,7 +235,7 @@ int mount_cgroup_controllers(char ***join_controllers) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return 0;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- controllers = set_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ controllers = set_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!controllers)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return log_oom();
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/core/swap.c b/src/core/swap.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 019d32ed0d..b88a914f72 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/core/swap.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/core/swap.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -77,7 +77,7 @@ static int swap_set_devnode(Swap *s, const char *devnode) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert(s);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&UNIT(s)->manager->swaps_by_devnode, string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&UNIT(s)->manager->swaps_by_devnode, &string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1226,7 +1226,7 @@ static int swap_following_set(Unit *u, Set **_set) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return 0;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- set = set_new(NULL, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ set = set_new(NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!set)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return -ENOMEM;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/core/transaction.c b/src/core/transaction.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 1f4c9ce416..dbb4133fe3 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/core/transaction.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/core/transaction.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1143,7 +1143,7 @@ Transaction *transaction_new(bool irreversible) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!tr)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- tr->jobs = hashmap_new(trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ tr->jobs = hashmap_new(NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!tr->jobs) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
free(tr);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/core/unit.c b/src/core/unit.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index b5c3182940..5978e21f56 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/core/unit.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/core/unit.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -81,7 +81,7 @@ Unit *unit_new(Manager *m, size_t size) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!u)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- u->names = set_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ u->names = set_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!u->names) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
free(u);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1843,17 +1843,17 @@ int unit_watch_pid(Unit *u, pid_t pid) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
/* Watch a specific PID. We only support one or two units
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
* watching each PID for now, not more. */
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = set_ensure_allocated(&u->pids, trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = set_ensure_allocated(&u->pids, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&u->manager->watch_pids1, trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&u->manager->watch_pids1, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
r = hashmap_put(u->manager->watch_pids1, LONG_TO_PTR(pid), u);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r == -EEXIST) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&u->manager->watch_pids2, trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&u->manager->watch_pids2, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -2086,22 +2086,22 @@ int unit_add_dependency(Unit *u, UnitDependency d, Unit *other, bool add_referen
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return 0;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = set_ensure_allocated(&u->dependencies[d], trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = set_ensure_allocated(&u->dependencies[d], NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (inverse_table[d] != _UNIT_DEPENDENCY_INVALID) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = set_ensure_allocated(&other->dependencies[inverse_table[d]], trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = set_ensure_allocated(&other->dependencies[inverse_table[d]], NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (add_reference) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = set_ensure_allocated(&u->dependencies[UNIT_REFERENCES], trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = set_ensure_allocated(&u->dependencies[UNIT_REFERENCES], NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = set_ensure_allocated(&other->dependencies[UNIT_REFERENCED_BY], trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = set_ensure_allocated(&other->dependencies[UNIT_REFERENCED_BY], NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -2847,7 +2847,7 @@ static Set *unit_pid_set(pid_t main_pid, pid_t control_pid) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Set *pid_set;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- pid_set = set_new(trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ pid_set = set_new(NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!pid_set)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -3385,7 +3385,7 @@ int unit_require_mounts_for(Unit *u, const char *path) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
char *q;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!u->manager->units_requiring_mounts_for) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- u->manager->units_requiring_mounts_for = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ u->manager->units_requiring_mounts_for = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!u->manager->units_requiring_mounts_for)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return -ENOMEM;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -3394,7 +3394,7 @@ int unit_require_mounts_for(Unit *u, const char *path) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!q)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return -ENOMEM;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- x = set_new(NULL, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ x = set_new(NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!x) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
free(q);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return -ENOMEM;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/delta/delta.c b/src/delta/delta.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index cd8bd35716..91f8592b40 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/delta/delta.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/delta/delta.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -268,7 +268,7 @@ static int enumerate_dir_d(Hashmap *top, Hashmap *bottom, Hashmap *drops, const
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
h = hashmap_get(drops, unit);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!h) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- h = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ h = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!h)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return -ENOMEM;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
hashmap_put(drops, unit, h);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -372,9 +372,9 @@ static int process_suffix(const char *suffix, const char *onlyprefix) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
dropins = nulstr_contains(have_dropins, suffix);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- top = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- bottom = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- drops = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ top = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ bottom = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ drops = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!top || !bottom || !drops) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
r = -ENOMEM;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
goto finish;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 1cc86aeaf3..12de820330 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/journal-remote/journal-remote.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/journal-remote/journal-remote.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -222,20 +222,14 @@ static int open_output(Writer *w, const char* host) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
**********************************************************************/
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
static int init_writer_hashmap(RemoteServer *s) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- static const struct {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- hash_func_t hash_func;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- compare_func_t compare_func;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- } functions[] = {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- [JOURNAL_WRITE_SPLIT_NONE] = {trivial_hash_func,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- trivial_compare_func},
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- [JOURNAL_WRITE_SPLIT_HOST] = {string_hash_func,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- string_compare_func},
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ static const struct hash_ops *hash_ops[] = {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ [JOURNAL_WRITE_SPLIT_NONE] = NULL,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ [JOURNAL_WRITE_SPLIT_HOST] = &string_hash_ops,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
};
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- assert(arg_split_mode >= 0 && arg_split_mode < (int) ELEMENTSOF(functions));
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ assert(arg_split_mode >= 0 && arg_split_mode < (int) ELEMENTSOF(hash_ops));
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- s->writers = hashmap_new(functions[arg_split_mode].hash_func,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- functions[arg_split_mode].compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ s->writers = hashmap_new(hash_ops[arg_split_mode]);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!s->writers)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return log_oom();
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -695,7 +689,7 @@ static int setup_microhttpd_server(RemoteServer *s,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
goto error;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&s->daemons, uint64_hash_func, uint64_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&s->daemons, &uint64_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
log_oom();
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
goto error;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/journal/catalog.c b/src/journal/catalog.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index f03357dedf..41d450b154 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/journal/catalog.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/journal/catalog.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -64,7 +64,7 @@ typedef struct CatalogItem {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
le64_t offset;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
} CatalogItem;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
-unsigned long catalog_hash_func(const void *p, const uint8_t hash_key[HASH_KEY_SIZE]) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+static unsigned long catalog_hash_func(const void *p, const uint8_t hash_key[HASH_KEY_SIZE]) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
const CatalogItem *i = p;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
uint64_t u;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
size_t l, sz;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -81,7 +81,7 @@ unsigned long catalog_hash_func(const void *p, const uint8_t hash_key[HASH_KEY_S
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return (unsigned long) u;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
-int catalog_compare_func(const void *a, const void *b) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+static int catalog_compare_func(const void *a, const void *b) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
const CatalogItem *i = a, *j = b;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
unsigned k;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -95,6 +95,11 @@ int catalog_compare_func(const void *a, const void *b) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return strcmp(i->language, j->language);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+const struct hash_ops catalog_hash_ops = {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ .hash = catalog_hash_func,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ .compare = catalog_compare_func
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+};
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
static int finish_item(
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Hashmap *h,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
struct strbuf *sb,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -407,7 +412,7 @@ int catalog_update(const char* database, const char* root, const char* const* di
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
unsigned n;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
long r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- h = hashmap_new(catalog_hash_func, catalog_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ h = hashmap_new(&catalog_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
sb = strbuf_new();
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!h || !sb) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/journal/catalog.h b/src/journal/catalog.h
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index fdde67aeed..a72ecf6de7 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/journal/catalog.h
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/journal/catalog.h
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -28,11 +28,10 @@
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
#include "strbuf.h"
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int catalog_import_file(Hashmap *h, struct strbuf *sb, const char *path);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
-unsigned long catalog_hash_func(const void *p, const uint8_t hash_key[HASH_KEY_SIZE]);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
-int catalog_compare_func(const void *a, const void *b) _pure_;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int catalog_update(const char* database, const char* root, const char* const* dirs);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int catalog_get(const char* database, sd_id128_t id, char **data);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int catalog_list(FILE *f, const char* database, bool oneline);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int catalog_list_items(FILE *f, const char* database, bool oneline, char **items);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int catalog_file_lang(const char *filename, char **lang);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
extern const char * const catalog_file_dirs[];
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+extern const struct hash_ops catalog_hash_ops;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/journal/coredump-vacuum.c b/src/journal/coredump-vacuum.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 125bb3a4b8..fec901e8e4 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/journal/coredump-vacuum.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/journal/coredump-vacuum.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -194,7 +194,7 @@ int coredump_vacuum(int exclude_fd, off_t keep_free, off_t max_use) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
exclude_st.st_ino == st.st_ino)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
continue;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&h, NULL, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&h, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return log_oom();
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/journal/coredumpctl.c b/src/journal/coredumpctl.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 34dcae87c0..d4756fe67d 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/journal/coredumpctl.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/journal/coredumpctl.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -58,7 +58,7 @@ static Set *new_matches(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
char *tmp;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- set = set_new(trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ set = set_new(NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!set) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
log_oom();
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 7286e14ddb..f25cda6ddc 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/journal/journal-file.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/journal/journal-file.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -2498,7 +2498,7 @@ int journal_file_open(
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
goto fail;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- f->chain_cache = hashmap_new(uint64_hash_func, uint64_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ f->chain_cache = hashmap_new(&uint64_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!f->chain_cache) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
r = -ENOMEM;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
goto fail;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index d00a815ba9..47206d383a 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/journal/journalctl.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/journal/journalctl.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1029,7 +1029,7 @@ static int get_possible_units(sd_journal *j,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
const char *field;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- found = set_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ found = set_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!found)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return log_oom();
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 01da38b8d8..3df7416397 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/journal/journald-server.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/journal/journald-server.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1483,7 +1483,7 @@ int server_init(Server *s) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
mkdir_p("/run/systemd/journal", 0755);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- s->user_journals = hashmap_new(trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ s->user_journals = hashmap_new(NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!s->user_journals)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return log_oom();
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/journal/mmap-cache.c b/src/journal/mmap-cache.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 908562da27..2d268fc332 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/journal/mmap-cache.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/journal/mmap-cache.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -227,7 +227,7 @@ static Context *context_add(MMapCache *m, unsigned id) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (c)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return c;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&m->contexts, trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&m->contexts, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -281,7 +281,7 @@ static FileDescriptor* fd_add(MMapCache *m, int fd) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (f)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return f;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&m->fds, trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&m->fds, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 693707cb34..1fc9f01d0a 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/journal/sd-journal.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/journal/sd-journal.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -70,7 +70,7 @@ static int set_put_error(sd_journal *j, int r) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r >= 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- k = set_ensure_allocated(&j->errors, trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ k = set_ensure_allocated(&j->errors, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (k < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return k;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1662,7 +1662,7 @@ static int allocate_inotify(sd_journal *j) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!j->directories_by_wd) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- j->directories_by_wd = hashmap_new(trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ j->directories_by_wd = hashmap_new(NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!j->directories_by_wd)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return -ENOMEM;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1688,8 +1688,8 @@ static sd_journal *journal_new(int flags, const char *path) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
goto fail;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- j->files = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- j->directories_by_path = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ j->files = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ j->directories_by_path = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
j->mmap = mmap_cache_new();
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!j->files || !j->directories_by_path || !j->mmap)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
goto fail;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/journal/test-catalog.c b/src/journal/test-catalog.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 967ab6756b..5fe2f6a269 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/journal/test-catalog.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/journal/test-catalog.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -62,7 +62,7 @@ static void test_catalog_importing(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Hashmap *h;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
struct strbuf *sb;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- assert_se(h = hashmap_new(catalog_hash_func, catalog_compare_func));
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ assert_se(h = hashmap_new(&catalog_hash_ops));
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_se(sb = strbuf_new());
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
#define BUF "xxx"
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/libsystemd-network/sd-dhcp-server.c b/src/libsystemd-network/sd-dhcp-server.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index ab683228b4..a6d6178e72 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/libsystemd-network/sd-dhcp-server.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/libsystemd-network/sd-dhcp-server.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -109,6 +109,11 @@ int client_id_compare_func(const void *_a, const void *_b) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return memcmp(a->data, b->data, a->length);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+static const struct hash_ops client_id_hash_ops = {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ .hash = client_id_hash_func,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ .compare = client_id_compare_func
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+};
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
static void dhcp_lease_free(DHCPLease *lease) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!lease)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -158,8 +163,7 @@ int sd_dhcp_server_new(sd_dhcp_server **ret, int ifindex) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
server->address = htobe32(INADDR_ANY);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
server->netmask = htobe32(INADDR_ANY);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
server->index = ifindex;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- server->leases_by_client_id = hashmap_new(client_id_hash_func,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- client_id_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ server->leases_by_client_id = hashmap_new(&client_id_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
*ret = server;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
server = NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/libsystemd/sd-bus/bus-match.c b/src/libsystemd/sd-bus/bus-match.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 88b61a75be..18afe0f12a 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/libsystemd/sd-bus/bus-match.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/libsystemd/sd-bus/bus-match.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -450,13 +450,13 @@ static int bus_match_add_compare_value(
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
where->child = c;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (t == BUS_MATCH_MESSAGE_TYPE) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- c->compare.children = hashmap_new(trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ c->compare.children = hashmap_new(NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!c->compare.children) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
r = -ENOMEM;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
goto fail;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
} else if (BUS_MATCH_CAN_HASH(t)) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- c->compare.children = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ c->compare.children = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!c->compare.children) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
r = -ENOMEM;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
goto fail;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/libsystemd/sd-bus/bus-objects.c b/src/libsystemd/sd-bus/bus-objects.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 3a2de6520e..81c840f129 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/libsystemd/sd-bus/bus-objects.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/libsystemd/sd-bus/bus-objects.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -225,7 +225,7 @@ static int get_child_nodes(
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert(n);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert(_s);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- s = set_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ s = set_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!s)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return -ENOMEM;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1420,7 +1420,7 @@ static struct node *bus_node_allocate(sd_bus *bus, const char *path) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (n)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return n;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&bus->nodes, string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&bus->nodes, &string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1590,6 +1590,11 @@ static int vtable_member_compare_func(const void *a, const void *b) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return strcmp(x->member, y->member);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+static const struct hash_ops vtable_member_hash_ops = {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ .hash = vtable_member_hash_func,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ .compare = vtable_member_compare_func
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+};
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
static int add_object_vtable_internal(
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
sd_bus *bus,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
sd_bus_slot **slot,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1618,11 +1623,11 @@ static int add_object_vtable_internal(
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
!streq(interface, "org.freedesktop.DBus.Peer") &&
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
!streq(interface, "org.freedesktop.DBus.ObjectManager"), -EINVAL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&bus->vtable_methods, vtable_member_hash_func, vtable_member_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&bus->vtable_methods, &vtable_member_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&bus->vtable_properties, vtable_member_hash_func, vtable_member_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&bus->vtable_properties, &vtable_member_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/libsystemd/sd-bus/bus-track.c b/src/libsystemd/sd-bus/bus-track.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index ffa2cf3d75..0a3322a4ee 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/libsystemd/sd-bus/bus-track.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/libsystemd/sd-bus/bus-track.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -166,7 +166,7 @@ _public_ int sd_bus_track_add_name(sd_bus_track *track, const char *name) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_return(track, -EINVAL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_return(service_name_is_valid(name), -EINVAL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&track->names, string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&track->names, &string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/libsystemd/sd-bus/bus-util.c b/src/libsystemd/sd-bus/bus-util.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index a85d36180e..7c6da60cca 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/libsystemd/sd-bus/bus-util.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/libsystemd/sd-bus/bus-util.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -399,7 +399,7 @@ int bus_verify_polkit_async(
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!sender)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return -EBADMSG;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(registry, trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(registry, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/libsystemd/sd-bus/busctl.c b/src/libsystemd/sd-bus/busctl.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index af71804410..f06b74505b 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/libsystemd/sd-bus/busctl.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/libsystemd/sd-bus/busctl.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -76,7 +76,7 @@ static int list_bus_names(sd_bus *bus, char **argv) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
pager_open_if_enabled();
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- names = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ names = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!names)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return log_oom();
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 83b3aa1c3c..33b65aba72 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/libsystemd/sd-bus/sd-bus.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/libsystemd/sd-bus/sd-bus.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1756,7 +1756,7 @@ _public_ int sd_bus_call_async(
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!BUS_IS_OPEN(bus->state))
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return -ENOTCONN;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&bus->reply_callbacks, uint64_hash_func, uint64_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&bus->reply_callbacks, &uint64_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 985ff2829b..b56182dda7 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/libsystemd/sd-event/sd-event.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/libsystemd/sd-event/sd-event.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1032,7 +1032,7 @@ _public_ int sd_event_add_child(
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_return(e->state != SD_EVENT_FINISHED, -ESTALE);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_return(!event_pid_changed(e), -ECHILD);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&e->child_sources, trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&e->child_sources, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1123,7 +1123,7 @@ _public_ int sd_event_add_post(
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_return(e->state != SD_EVENT_FINISHED, -ESTALE);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_return(!event_pid_changed(e), -ECHILD);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = set_ensure_allocated(&e->post_sources, trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = set_ensure_allocated(&e->post_sources, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/libsystemd/sd-rtnl/sd-rtnl.c b/src/libsystemd/sd-rtnl/sd-rtnl.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index a3f314b95b..b7f1afe905 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/libsystemd/sd-rtnl/sd-rtnl.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/libsystemd/sd-rtnl/sd-rtnl.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -557,7 +557,7 @@ int sd_rtnl_call_async(sd_rtnl *nl,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_return(callback, -EINVAL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_return(!rtnl_pid_changed(nl), -ECHILD);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&nl->reply_callbacks, uint64_hash_func, uint64_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&nl->reply_callbacks, &uint64_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/locale/localectl.c b/src/locale/localectl.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 2bb0d3b6be..bf8b7b2bef 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/locale/localectl.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/locale/localectl.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -272,7 +272,7 @@ static int list_vconsole_keymaps(sd_bus *bus, char **args, unsigned n) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
_cleanup_strv_free_ char **l = NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
const char *dir;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- keymaps = set_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ keymaps = set_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!keymaps)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return log_oom();
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/login/logind-acl.c b/src/login/logind-acl.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index b76e16d906..f7c6f3a4ef 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/login/logind-acl.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/login/logind-acl.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -190,7 +190,7 @@ int devnode_acl_all(struct udev *udev,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert(udev);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- nodes = set_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ nodes = set_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!nodes)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return -ENOMEM;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 10a43a4a30..eeb58c9031 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/login/logind-session.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/login/logind-session.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -61,7 +61,7 @@ Session* session_new(Manager *m, const char *id) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- s->devices = hashmap_new(devt_hash_func, devt_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ s->devices = hashmap_new(&devt_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!s->devices) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
free(s->state_file);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
free(s);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/login/logind.c b/src/login/logind.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 1f94a97bd0..f1b6a86298 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/login/logind.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/login/logind.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -64,17 +64,17 @@ Manager *manager_new(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
m->runtime_dir_size = PAGE_ALIGN((size_t) (physical_memory() / 10)); /* 10% */
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- m->devices = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- m->seats = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- m->sessions = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- m->users = hashmap_new(trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- m->inhibitors = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- m->buttons = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ m->devices = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ m->seats = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ m->sessions = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ m->users = hashmap_new(NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ m->inhibitors = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ m->buttons = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- m->user_units = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- m->session_units = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ m->user_units = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ m->session_units = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- m->busnames = set_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ m->busnames = set_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!m->devices || !m->seats || !m->sessions || !m->users || !m->inhibitors || !m->buttons || !m->busnames ||
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
!m->user_units || !m->session_units)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/machine/machined.c b/src/machine/machined.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index aac670ba78..71c8189d5f 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/machine/machined.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/machine/machined.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -44,9 +44,9 @@ Manager *manager_new(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!m)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- m->machines = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- m->machine_units = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- m->machine_leaders = hashmap_new(trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ m->machines = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ m->machine_units = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ m->machine_leaders = hashmap_new(NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!m->machines || !m->machine_units || !m->machine_leaders) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
manager_free(m);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 11ac1307d8..9bf1a811c9 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/network/networkd-link.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/network/networkd-link.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -206,7 +206,7 @@ static int link_new(Manager *manager, sd_rtnl_message *message, Link **ret) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return -ENOMEM;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&manager->links, NULL, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&manager->links, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 1614bc0091..2213ad717c 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/network/networkd-manager.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/network/networkd-manager.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -115,7 +115,7 @@ int manager_new(Manager **ret) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return -ENOMEM;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- m->netdevs = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ m->netdevs = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!m->netdevs)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return -ENOMEM;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -485,15 +485,15 @@ int manager_save(Manager *m) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert(m->state_file);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
/* We add all NTP and DNS server to a set, to filter out duplicates */
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- dns = set_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ dns = set_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!dns)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return -ENOMEM;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- ntp = set_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ ntp = set_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!ntp)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return -ENOMEM;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- domains = set_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ domains = set_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!domains)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return -ENOMEM;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index a2e27e0910..aad99236c4 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/network/networkd-network.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/network/networkd-network.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -63,15 +63,15 @@ static int network_load_one(Manager *manager, const char *filename) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
LIST_HEAD_INIT(network->static_addresses);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
LIST_HEAD_INIT(network->static_routes);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- network->stacked_netdevs = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ network->stacked_netdevs = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!network->stacked_netdevs)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return log_oom();
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- network->addresses_by_section = hashmap_new(NULL, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ network->addresses_by_section = hashmap_new(NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!network->addresses_by_section)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return log_oom();
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- network->routes_by_section = hashmap_new(NULL, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ network->routes_by_section = hashmap_new(NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!network->routes_by_section)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return log_oom();
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/network/networkd-wait-online-link.c b/src/network/networkd-wait-online-link.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index f23c7ceb80..268ab676c9 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/network/networkd-wait-online-link.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/network/networkd-wait-online-link.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -34,12 +34,11 @@ int link_new(Manager *m, Link **ret, int ifindex, const char *ifname) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert(m);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert(ifindex > 0);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&m->links, NULL, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&m->links, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&m->links_by_name,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&m->links_by_name, &string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/readahead/readahead-collect.c b/src/readahead/readahead-collect.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 1592cc8678..822a803a41 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/readahead/readahead-collect.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/readahead/readahead-collect.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -282,7 +282,7 @@ static int collect(const char *root) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
goto finish;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- files = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ files = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!files) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
log_error("Failed to allocate set.");
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
r = -ENOMEM;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/remount-fs/remount-fs.c b/src/remount-fs/remount-fs.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 847637a12c..cd7cfe7a47 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/remount-fs/remount-fs.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/remount-fs/remount-fs.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -64,7 +64,7 @@ int main(int argc, char *argv[]) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return EXIT_FAILURE;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- pids = hashmap_new(trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ pids = hashmap_new(NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!pids) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
log_error("Failed to allocate set");
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
goto finish;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/resolve/resolved-dns-cache.c b/src/resolve/resolved-dns-cache.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 733ef6348d..33ca4d1a45 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/resolve/resolved-dns-cache.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/resolve/resolved-dns-cache.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -186,7 +186,7 @@ static int dns_cache_init(DnsCache *c) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&c->by_key, dns_resource_key_hash_func, dns_resource_key_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&c->by_key, &dns_resource_key_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/resolve/resolved-dns-domain.c b/src/resolve/resolved-dns-domain.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 8ed1ecf0a4..e1eb3ddfe5 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/resolve/resolved-dns-domain.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/resolve/resolved-dns-domain.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -371,6 +371,11 @@ int dns_name_compare_func(const void *a, const void *b) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+const struct hash_ops dns_name_hash_ops = {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ .hash = dns_name_hash_func,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ .compare = dns_name_compare_func
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+};
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int dns_name_equal(const char *x, const char *y) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int r, q, k, w;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/resolve/resolved-dns-domain.h b/src/resolve/resolved-dns-domain.h
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index e674c5d9c5..0888a7846f 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/resolve/resolved-dns-domain.h
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/resolve/resolved-dns-domain.h
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -37,6 +37,7 @@ int dns_name_normalize(const char *s, char **_ret);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
unsigned long dns_name_hash_func(const void *s, const uint8_t hash_key[HASH_KEY_SIZE]);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int dns_name_compare_func(const void *a, const void *b);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+extern const struct hash_ops dns_name_hash_ops;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int dns_name_equal(const char *x, const char *y);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int dns_name_endswith(const char *name, const char *suffix);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/resolve/resolved-dns-packet.c b/src/resolve/resolved-dns-packet.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 0d276df8c9..7375f77481 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/resolve/resolved-dns-packet.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/resolve/resolved-dns-packet.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -433,9 +433,7 @@ int dns_packet_append_name(DnsPacket *p, const char *name,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
goto fail;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (allow_compression) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&p->names,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- dns_name_hash_func,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- dns_name_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&p->names, &dns_name_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
goto fail;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/resolve/resolved-dns-query.c b/src/resolve/resolved-dns-query.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 669595d7f9..f0483c9806 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/resolve/resolved-dns-query.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/resolve/resolved-dns-query.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -144,7 +144,7 @@ static int dns_query_add_transaction(DnsQuery *q, DnsScope *s, DnsResourceKey *k
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert(q);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert(s);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = set_ensure_allocated(&q->transactions, NULL, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = set_ensure_allocated(&q->transactions, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -166,7 +166,7 @@ static int dns_query_add_transaction(DnsQuery *q, DnsScope *s, DnsResourceKey *k
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = set_ensure_allocated(&t->queries, NULL, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = set_ensure_allocated(&t->queries, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
goto gc;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/resolve/resolved-dns-rr.c b/src/resolve/resolved-dns-rr.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index c5f7cb931e..fd5ecf413d 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/resolve/resolved-dns-rr.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/resolve/resolved-dns-rr.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -133,7 +133,7 @@ int dns_resource_key_match_cname(const DnsResourceKey *key, const DnsResourceRec
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return dns_name_equal(DNS_RESOURCE_KEY_NAME(rr->key), DNS_RESOURCE_KEY_NAME(key));
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
-unsigned long dns_resource_key_hash_func(const void *i, const uint8_t hash_key[HASH_KEY_SIZE]) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+static unsigned long dns_resource_key_hash_func(const void *i, const uint8_t hash_key[HASH_KEY_SIZE]) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
const DnsResourceKey *k = i;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
unsigned long ul;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -144,7 +144,7 @@ unsigned long dns_resource_key_hash_func(const void *i, const uint8_t hash_key[H
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return ul;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
-int dns_resource_key_compare_func(const void *a, const void *b) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+static int dns_resource_key_compare_func(const void *a, const void *b) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
const DnsResourceKey *x = a, *y = b;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int ret;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -165,6 +165,11 @@ int dns_resource_key_compare_func(const void *a, const void *b) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return 0;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+const struct hash_ops dns_resource_key_hash_ops = {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ .hash = dns_resource_key_hash_func,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ .compare = dns_resource_key_compare_func
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+};
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int dns_resource_key_to_string(const DnsResourceKey *key, char **ret) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
char cbuf[DECIMAL_STR_MAX(uint16_t)], tbuf[DECIMAL_STR_MAX(uint16_t)];
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
const char *c, *t;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/resolve/resolved-dns-rr.h b/src/resolve/resolved-dns-rr.h
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 3222f1f0ee..9d9a89d383 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/resolve/resolved-dns-rr.h
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/resolve/resolved-dns-rr.h
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -159,8 +159,6 @@ DnsResourceKey* dns_resource_key_unref(DnsResourceKey *key);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int dns_resource_key_equal(const DnsResourceKey *a, const DnsResourceKey *b);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int dns_resource_key_match_rr(const DnsResourceKey *key, const DnsResourceRecord *rr);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int dns_resource_key_match_cname(const DnsResourceKey *key, const DnsResourceRecord *rr);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
-unsigned long dns_resource_key_hash_func(const void *i, const uint8_t hash_key[HASH_KEY_SIZE]);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
-int dns_resource_key_compare_func(const void *a, const void *b);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int dns_resource_key_to_string(const DnsResourceKey *key, char **ret);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
DEFINE_TRIVIAL_CLEANUP_FUNC(DnsResourceKey*, dns_resource_key_unref);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -175,3 +173,5 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(DnsResourceRecord*, dns_resource_record_unref);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
const char *dns_class_to_string(uint16_t type);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int dns_class_from_string(const char *name, uint16_t *class);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+extern const struct hash_ops dns_resource_key_hash_ops;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/resolve/resolved-dns-scope.c b/src/resolve/resolved-dns-scope.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 039a754ff0..40d59922d1 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/resolve/resolved-dns-scope.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/resolve/resolved-dns-scope.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -709,7 +709,7 @@ int dns_scope_notify_conflict(DnsScope *scope, DnsResourceRecord *rr) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
/* We don't send these queries immediately. Instead, we queue
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
* them, and send them after some jitter delay. */
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&scope->conflict_queue, dns_resource_key_hash_func, dns_resource_key_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&scope->conflict_queue, &dns_resource_key_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
log_oom();
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/resolve/resolved-dns-server.c b/src/resolve/resolved-dns-server.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index c99768be4f..caf06fe450 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/resolve/resolved-dns-server.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/resolve/resolved-dns-server.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -100,7 +100,7 @@ DnsServer* dns_server_free(DnsServer *s) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
-unsigned long dns_server_hash_func(const void *p, const uint8_t hash_key[HASH_KEY_SIZE]) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+static unsigned long dns_server_hash_func(const void *p, const uint8_t hash_key[HASH_KEY_SIZE]) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
const DnsServer *s = p;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
uint64_t u;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -110,7 +110,7 @@ unsigned long dns_server_hash_func(const void *p, const uint8_t hash_key[HASH_KE
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return u;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
-int dns_server_compare_func(const void *a, const void *b) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+static int dns_server_compare_func(const void *a, const void *b) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
const DnsServer *x = a, *y = b;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (x->family < y->family)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -120,3 +120,8 @@ int dns_server_compare_func(const void *a, const void *b) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return memcmp(&x->address, &y->address, FAMILY_ADDRESS_SIZE(x->family));
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+const struct hash_ops dns_server_hash_ops = {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ .hash = dns_server_hash_func,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ .compare = dns_server_compare_func
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+};
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/resolve/resolved-dns-server.h b/src/resolve/resolved-dns-server.h
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index f2361a8385..a438a27763 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/resolve/resolved-dns-server.h
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/resolve/resolved-dns-server.h
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -60,5 +60,4 @@ int dns_server_new(
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
DnsServer* dns_server_free(DnsServer *s);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
-unsigned long dns_server_hash_func(const void *p, const uint8_t hash_key[HASH_KEY_SIZE]);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
-int dns_server_compare_func(const void *a, const void *b);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+extern const struct hash_ops dns_server_hash_ops;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/resolve/resolved-dns-transaction.c b/src/resolve/resolved-dns-transaction.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 990b1f2e43..74b0634142 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/resolve/resolved-dns-transaction.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/resolve/resolved-dns-transaction.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -78,7 +78,7 @@ int dns_transaction_new(DnsTransaction **ret, DnsScope *s, DnsQuestion *q) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert(s);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert(q);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&s->manager->dns_transactions, NULL, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&s->manager->dns_transactions, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/resolve/resolved-dns-zone.c b/src/resolve/resolved-dns-zone.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index b53e957d76..8098ff5e70 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/resolve/resolved-dns-zone.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/resolve/resolved-dns-zone.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -126,11 +126,11 @@ static int dns_zone_init(DnsZone *z) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert(z);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&z->by_key, dns_resource_key_hash_func, dns_resource_key_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&z->by_key, &dns_resource_key_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&z->by_name, dns_name_hash_func, dns_name_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&z->by_name, &dns_name_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -194,7 +194,7 @@ static int dns_zone_item_probe_start(DnsZoneItem *i) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = set_ensure_allocated(&t->zone_items, NULL, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = set_ensure_allocated(&t->zone_items, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
goto gc;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/resolve/resolved-link.c b/src/resolve/resolved-link.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index f47017ced8..4def672214 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/resolve/resolved-link.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/resolve/resolved-link.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -33,7 +33,7 @@ int link_new(Manager *m, Link **ret, int ifindex) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert(m);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert(ifindex > 0);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&m->links, NULL, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&m->links, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/resolve/resolved-manager.c b/src/resolve/resolved-manager.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 00aaffe448..63d7845387 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/resolve/resolved-manager.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/resolve/resolved-manager.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -737,11 +737,11 @@ int manager_write_resolv_conf(Manager *m) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
manager_read_resolv_conf(m);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
/* Add the full list to a set, to filter out duplicates */
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- dns = set_new(dns_server_hash_func, dns_server_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ dns = set_new(&dns_server_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!dns)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return -ENOMEM;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- domains = set_new(dns_name_hash_func, dns_name_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ domains = set_new(&dns_name_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!domains)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return -ENOMEM;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/shared/cgroup-util.c b/src/shared/cgroup-util.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 00eac64236..da8e885226 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/shared/cgroup-util.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/shared/cgroup-util.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -161,7 +161,7 @@ int cg_kill(const char *controller, const char *path, int sig, bool sigcont, boo
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
* tasks list, to properly handle forking processes */
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!s) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- s = allocated_set = set_new(trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ s = allocated_set = set_new(NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!s)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return -ENOMEM;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -239,7 +239,7 @@ int cg_kill_recursive(const char *controller, const char *path, int sig, bool si
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert(sig >= 0);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!s) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- s = allocated_set = set_new(trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ s = allocated_set = set_new(NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!s)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return -ENOMEM;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -290,7 +290,7 @@ int cg_migrate(const char *cfrom, const char *pfrom, const char *cto, const char
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert(cto);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert(pto);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- s = set_new(trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ s = set_new(NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!s)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return -ENOMEM;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/shared/conf-files.c b/src/shared/conf-files.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index c72a099b5a..e6ee97a978 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/shared/conf-files.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/shared/conf-files.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -109,7 +109,7 @@ static int conf_files_list_strv_internal(char ***strv, const char *suffix, const
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!path_strv_resolve_uniq(dirs, root))
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return -ENOMEM;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- fh = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ fh = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!fh)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return -ENOMEM;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/shared/fdset.c b/src/shared/fdset.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index d2ea665016..37cbd8526c 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/shared/fdset.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/shared/fdset.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -38,7 +38,7 @@
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
#define PTR_TO_FD(p) (PTR_TO_INT(p)-1)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
FDSet *fdset_new(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- return MAKE_FDSET(set_new(trivial_hash_func, trivial_compare_func));
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ return MAKE_FDSET(set_new(NULL));
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
void fdset_free(FDSet *s) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/shared/hashmap.c b/src/shared/hashmap.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index dbf91c439e..715484ce7c 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/shared/hashmap.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/shared/hashmap.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -39,8 +39,7 @@ struct hashmap_entry {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
};
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
struct Hashmap {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- hash_func_t hash_func;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- compare_func_t compare_func;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ const struct hash_ops *hash_ops;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
struct hashmap_entry *iterate_list_head, *iterate_list_tail;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -141,6 +140,11 @@ int string_compare_func(const void *a, const void *b) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return strcmp(a, b);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+const struct hash_ops string_hash_ops = {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ .hash = string_hash_func,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ .compare = string_compare_func
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+};
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
unsigned long trivial_hash_func(const void *p, const uint8_t hash_key[HASH_KEY_SIZE]) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
uint64_t u;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
siphash24((uint8_t*) &u, &p, sizeof(p), hash_key);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -151,6 +155,11 @@ int trivial_compare_func(const void *a, const void *b) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return a < b ? -1 : (a > b ? 1 : 0);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+const struct hash_ops trivial_hash_ops = {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ .hash = trivial_hash_func,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ .compare = trivial_compare_func
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+};
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
unsigned long uint64_hash_func(const void *p, const uint8_t hash_key[HASH_KEY_SIZE]) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
uint64_t u;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
siphash24((uint8_t*) &u, p, sizeof(uint64_t), hash_key);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -164,6 +173,11 @@ int uint64_compare_func(const void *_a, const void *_b) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return a < b ? -1 : (a > b ? 1 : 0);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+const struct hash_ops uint64_hash_ops = {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ .hash = uint64_hash_func,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ .compare = uint64_compare_func
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+};
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
#if SIZEOF_DEV_T != 8
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
unsigned long devt_hash_func(const void *p, const uint8_t hash_key[HASH_KEY_SIZE]) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
uint64_t u;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -177,10 +191,15 @@ int devt_compare_func(const void *_a, const void *_b) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
b = *(const dev_t*) _b;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return a < b ? -1 : (a > b ? 1 : 0);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+const struct hash_ops devt_hash_ops = {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ .hash = devt_hash_func,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ .compare = devt_compare_func
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+};
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
#endif
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
static unsigned bucket_hash(Hashmap *h, const void *p) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- return (unsigned) (h->hash_func(p, h->hash_key) % h->n_buckets);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ return (unsigned) (h->hash_ops->hash(p, h->hash_key) % h->n_buckets);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
static void get_hash_key(uint8_t hash_key[HASH_KEY_SIZE], bool reuse_is_ok) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -202,7 +221,7 @@ static void get_hash_key(uint8_t hash_key[HASH_KEY_SIZE], bool reuse_is_ok) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
memcpy(hash_key, current, sizeof(current));
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
-Hashmap *hashmap_new(hash_func_t hash_func, compare_func_t compare_func) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+Hashmap *hashmap_new(const struct hash_ops *hash_ops) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
bool b;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Hashmap *h;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
size_t size;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -224,8 +243,7 @@ Hashmap *hashmap_new(hash_func_t hash_func, compare_func_t compare_func) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- h->hash_func = hash_func ? hash_func : trivial_hash_func;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- h->compare_func = compare_func ? compare_func : trivial_compare_func;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ h->hash_ops = hash_ops ? hash_ops : &trivial_hash_ops;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
h->n_buckets = INITIAL_N_BUCKETS;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
h->n_entries = 0;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -240,7 +258,7 @@ Hashmap *hashmap_new(hash_func_t hash_func, compare_func_t compare_func) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return h;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
-int hashmap_ensure_allocated(Hashmap **h, hash_func_t hash_func, compare_func_t compare_func) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+int hashmap_ensure_allocated(Hashmap **h, const struct hash_ops *hash_ops) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Hashmap *q;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert(h);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -248,7 +266,7 @@ int hashmap_ensure_allocated(Hashmap **h, hash_func_t hash_func, compare_func_t
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (*h)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return 0;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- q = hashmap_new(hash_func, compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ q = hashmap_new(hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!q)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return -ENOMEM;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -406,7 +424,7 @@ static struct hashmap_entry *hash_scan(Hashmap *h, unsigned hash, const void *ke
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert(hash < h->n_buckets);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
for (e = h->buckets[hash]; e; e = e->bucket_next)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- if (h->compare_func(e->key, key) == 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (h->hash_ops->compare(e->key, key) == 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return e;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -438,7 +456,7 @@ static bool resize_buckets(Hashmap *h) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
for (i = h->iterate_list_head; i; i = i->iterate_next) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
unsigned long old_bucket, new_bucket;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- old_bucket = h->hash_func(i->key, h->hash_key) % h->n_buckets;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ old_bucket = h->hash_ops->hash(i->key, h->hash_key) % h->n_buckets;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
/* First, drop from old bucket table */
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (i->bucket_next)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -450,7 +468,7 @@ static bool resize_buckets(Hashmap *h) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
h->buckets[old_bucket] = i->bucket_next;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
/* Then, add to new backet table */
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- new_bucket = h->hash_func(i->key, nkey) % m;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ new_bucket = h->hash_ops->hash(i->key, nkey) % m;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
i->bucket_next = n[new_bucket];
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
i->bucket_previous = NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -949,7 +967,7 @@ Hashmap *hashmap_copy(Hashmap *h) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert(h);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- copy = hashmap_new(h->hash_func, h->compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ copy = hashmap_new(h->hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!copy)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/shared/hashmap.h b/src/shared/hashmap.h
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index f89e7e8fbc..7385ebc5fa 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/shared/hashmap.h
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/shared/hashmap.h
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -43,38 +43,50 @@ typedef _IteratorStruct* Iterator;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
typedef unsigned long (*hash_func_t)(const void *p, const uint8_t hash_key[HASH_KEY_SIZE]);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
typedef int (*compare_func_t)(const void *a, const void *b);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+struct hash_ops {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ hash_func_t hash;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ compare_func_t compare;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+};
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
unsigned long string_hash_func(const void *p, const uint8_t hash_key[HASH_KEY_SIZE]) _pure_;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int string_compare_func(const void *a, const void *b) _pure_;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+extern const struct hash_ops string_hash_ops;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
/* This will compare the passed pointers directly, and will not
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
* dereference them. This is hence not useful for strings or
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
* suchlike. */
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
unsigned long trivial_hash_func(const void *p, const uint8_t hash_key[HASH_KEY_SIZE]) _pure_;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int trivial_compare_func(const void *a, const void *b) _const_;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+extern const struct hash_ops trivial_hash_ops;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
/* 32bit values we can always just embedd in the pointer itself, but
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
* in order to support 32bit archs we need store 64bit values
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
* indirectly, since they don't fit in a pointer. */
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
unsigned long uint64_hash_func(const void *p, const uint8_t hash_key[HASH_KEY_SIZE]) _pure_;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int uint64_compare_func(const void *a, const void *b) _pure_;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+extern const struct hash_ops uint64_hash_ops;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
/* On some archs dev_t is 32bit, and on others 64bit. And sometimes
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
* it's 64bit on 32bit archs, and sometimes 32bit on 64bit archs. Yuck! */
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
#if SIZEOF_DEV_T != 8
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
unsigned long devt_hash_func(const void *p, const uint8_t hash_key[HASH_KEY_SIZE]) _pure_;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int devt_compare_func(const void *a, const void *b) _pure_;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+extern const struct hash_ops devt_hash_ops = {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ .hash = devt_hash_func,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ .compare = devt_compare_func
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+};
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
#else
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
-/* No need to define a second version of this... */
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
#define devt_hash_func uint64_hash_func
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
#define devt_compare_func uint64_compare_func
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+#define devt_hash_ops uint64_hash_ops
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
#endif
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
-Hashmap *hashmap_new(hash_func_t hash_func, compare_func_t compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+Hashmap *hashmap_new(const struct hash_ops *hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
void hashmap_free(Hashmap *h);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
void hashmap_free_free(Hashmap *h);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
void hashmap_free_free_free(Hashmap *h);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Hashmap *hashmap_copy(Hashmap *h);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
-int hashmap_ensure_allocated(Hashmap **h, hash_func_t hash_func, compare_func_t compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+int hashmap_ensure_allocated(Hashmap **h, const struct hash_ops *hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int hashmap_put(Hashmap *h, const void *key, void *value);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int hashmap_update(Hashmap *h, const void *key, void *value);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/shared/install.c b/src/shared/install.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 3ef995a928..5d3fcf5e32 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/shared/install.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/shared/install.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -179,7 +179,7 @@ static int mark_symlink_for_removal(
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert(p);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = set_ensure_allocated(remove_symlinks_to, string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = set_ensure_allocated(remove_symlinks_to, &string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -884,7 +884,7 @@ static int install_info_add(
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
hashmap_get(c->will_install, name))
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return 0;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&c->will_install, string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&c->will_install, &string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1393,7 +1393,7 @@ static int install_context_apply(
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
while ((i = hashmap_first(c->will_install))) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- q = hashmap_ensure_allocated(&c->have_installed, string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ q = hashmap_ensure_allocated(&c->have_installed, &string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (q < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return q;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1434,7 +1434,7 @@ static int install_context_mark_for_removal(
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
while ((i = hashmap_first(c->will_install))) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- q = hashmap_ensure_allocated(&c->have_installed, string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ q = hashmap_ensure_allocated(&c->have_installed, &string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (q < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return q;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/shared/locale-util.c b/src/shared/locale-util.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 8d2c363036..68851ae13d 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/shared/locale-util.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/shared/locale-util.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -160,7 +160,7 @@ int get_locales(char ***ret) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
_cleanup_strv_free_ char **l = NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- locales = set_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ locales = set_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!locales)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return -ENOMEM;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 5538dd3b9e..5a7bbaf03a 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/shared/logs-show.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/shared/logs-show.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -695,7 +695,7 @@ static int output_json(
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
sd_id128_to_string(boot_id, sid));
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- h = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ h = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!h)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return -ENOMEM;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/shared/set.c b/src/shared/set.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 02ea831593..d4ffe056d5 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/shared/set.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/shared/set.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -30,8 +30,8 @@
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
/* For now this is not much more than a wrapper around a hashmap */
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
-Set *set_new(hash_func_t hash_func, compare_func_t compare_func) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- return MAKE_SET(hashmap_new(hash_func, compare_func));
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+Set *set_new(const struct hash_ops *hash_ops) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ return MAKE_SET(hashmap_new(hash_ops));
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
void set_free(Set* s) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -42,8 +42,8 @@ void set_free_free(Set *s) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
hashmap_free_free(MAKE_HASHMAP(s));
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
-int set_ensure_allocated(Set **s, hash_func_t hash_func, compare_func_t compare_func) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- return hashmap_ensure_allocated((Hashmap**) s, hash_func, compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+int set_ensure_allocated(Set **s, const struct hash_ops *hash_ops) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ return hashmap_ensure_allocated((Hashmap**) s, hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int set_put(Set *s, void *value) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/shared/set.h b/src/shared/set.h
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index e0b9c9e0a8..e650b7e3fe 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/shared/set.h
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/shared/set.h
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -32,12 +32,12 @@
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
typedef struct Set Set;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
-Set *set_new(hash_func_t hash_func, compare_func_t compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+Set *set_new(const struct hash_ops *hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
void set_free(Set* s);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
void set_free_free(Set *s);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Set* set_copy(Set *s);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
-int set_ensure_allocated(Set **s, hash_func_t hash_func, compare_func_t compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+int set_ensure_allocated(Set **s, const struct hash_ops *hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int set_put(Set *s, void *value);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int set_consume(Set *s, void *value);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/shared/util.c b/src/shared/util.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 502b3675b1..61d6680ddd 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/shared/util.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/shared/util.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -3911,7 +3911,7 @@ void execute_directory(const char *directory, DIR *d, usec_t timeout, char *argv
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- pids = hashmap_new(NULL, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ pids = hashmap_new(NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!pids) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
log_oom();
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
_exit(EXIT_FAILURE);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -6694,7 +6694,7 @@ int bind_remount_recursive(const char *prefix, bool ro) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
path_kill_slashes(cleaned);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- done = set_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ done = set_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!done)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return -ENOMEM;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -6704,7 +6704,7 @@ int bind_remount_recursive(const char *prefix, bool ro) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
bool top_autofs = false;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
char *x;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- todo = set_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ todo = set_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!todo)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return -ENOMEM;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/socket-proxy/socket-proxyd.c b/src/socket-proxy/socket-proxyd.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index f6e6672cdf..81d8457fdd 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/socket-proxy/socket-proxyd.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/socket-proxy/socket-proxyd.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -473,7 +473,7 @@ static int add_connection_socket(Context *context, int fd) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return 0;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = set_ensure_allocated(&context->connections, trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = set_ensure_allocated(&context->connections, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
log_oom();
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return 0;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -543,7 +543,7 @@ static int add_listen_socket(Context *context, int fd) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert(context);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert(fd >= 0);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = set_ensure_allocated(&context->listen, trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = set_ensure_allocated(&context->listen, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
log_oom();
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/sysctl/sysctl.c b/src/sysctl/sysctl.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 8ce9870432..4f9530baf8 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/sysctl/sysctl.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/sysctl/sysctl.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -292,7 +292,7 @@ int main(int argc, char *argv[]) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
umask(0022);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- sysctl_options = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ sysctl_options = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!sysctl_options) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
r = log_oom();
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
goto finish;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index de43c879a7..88be871f32 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/systemctl/systemctl.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/systemctl/systemctl.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -594,7 +594,7 @@ static int get_unit_list_recursive(
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert(_unit_infos);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert(_machines);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- replies = set_new(NULL, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ replies = set_new(NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!replies)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return log_oom();
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1338,7 +1338,7 @@ static int list_unit_files(sd_bus *bus, char **args) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Iterator i;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
unsigned n_units;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- h = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ h = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!h)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return log_oom();
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -2746,7 +2746,7 @@ static int start_unit(sd_bus *bus, char **args) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- s = set_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ s = set_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!s)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return log_oom();
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index b889ed0536..ba20d949dc 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/sysusers/sysusers.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/sysusers/sysusers.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -107,11 +107,11 @@ static int load_user_database(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!f)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return errno == ENOENT ? 0 : -errno;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&database_user, string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&database_user, &string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&database_uid, trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&database_uid, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -159,11 +159,11 @@ static int load_group_database(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!f)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return errno == ENOENT ? 0 : -errno;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&database_group, string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&database_group, &string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&database_gid, trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&database_gid, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -969,7 +969,7 @@ static int add_user(Item *i) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
i->uid = search_uid;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&todo_uids, trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&todo_uids, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return log_oom();
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1122,7 +1122,7 @@ static int add_group(Item *i) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
i->gid = search_uid;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&todo_gids, trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&todo_gids, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return log_oom();
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1210,7 +1210,7 @@ static int add_implicit(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!i) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
_cleanup_(item_freep) Item *j = NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&groups, string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&groups, &string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return log_oom();
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1237,7 +1237,7 @@ static int add_implicit(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!i) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
_cleanup_(item_freep) Item *j = NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&users, string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&users, &string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return log_oom();
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1542,7 +1542,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return -EINVAL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&members, string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&members, &string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return log_oom();
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1584,7 +1584,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return -EINVAL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&users, string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&users, &string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return log_oom();
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1634,7 +1634,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return -EINVAL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = hashmap_ensure_allocated(&groups, string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = hashmap_ensure_allocated(&groups, &string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return log_oom();
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 368d420df3..6c3281ff15 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/sysv-generator/sysv-generator.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/sysv-generator/sysv-generator.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -824,8 +824,7 @@ static int set_dependencies_from_rcnd(LookupPaths lp, Hashmap *all_services) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
MAX(a*10 + b, service->sysv_start_priority);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = set_ensure_allocated(&runlevel_services[i],
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = set_ensure_allocated(&runlevel_services[i], NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
goto finish;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -836,8 +835,7 @@ static int set_dependencies_from_rcnd(LookupPaths lp, Hashmap *all_services) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
} else if (de->d_name[0] == 'K' &&
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
(rcnd_table[i].type == RUNLEVEL_DOWN)) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- r = set_ensure_allocated(&shutdown_services,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- trivial_hash_func, trivial_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = set_ensure_allocated(&shutdown_services, NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
goto finish;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -905,7 +903,7 @@ int main(int argc, char *argv[]) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return EXIT_FAILURE;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- all_services = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ all_services = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!all_services) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
log_oom();
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return EXIT_FAILURE;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/test/test-hashmap.c b/src/test/test-hashmap.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index ccef61f55c..95a7f8379d 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/test/test-hashmap.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/test/test-hashmap.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -26,7 +26,7 @@ static void test_hashmap_replace(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Hashmap *m;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
char *val1, *val2, *val3, *val4, *val5, *r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- m = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ m = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
val1 = strdup("val1");
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_se(val1);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -73,7 +73,7 @@ static void test_hashmap_copy(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
val4 = strdup("val4");
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_se(val4);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- m = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ m = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
hashmap_put(m, "key 1", val1);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
hashmap_put(m, "key 2", val2);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -109,7 +109,7 @@ static void test_hashmap_get_strv(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
val4 = strdup("val4");
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_se(val4);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- m = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ m = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
hashmap_put(m, "key 1", val1);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
hashmap_put(m, "key 2", val2);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -141,8 +141,8 @@ static void test_hashmap_move_one(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
val4 = strdup("val4");
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_se(val4);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- m = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- n = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ m = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ n = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
hashmap_put(m, "key 1", val1);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
hashmap_put(m, "key 2", val2);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -168,7 +168,7 @@ static void test_hashmap_next(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Hashmap *m;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
char *val1, *val2, *val3, *val4, *r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- m = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ m = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
val1 = strdup("val1");
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_se(val1);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
val2 = strdup("val2");
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -199,7 +199,7 @@ static void test_hashmap_update(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Hashmap *m;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
char *val1, *val2, *r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- m = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ m = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
val1 = strdup("old_value");
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_se(val1);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
val2 = strdup("new_value");
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -222,7 +222,7 @@ static void test_hashmap_put(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Hashmap *m;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int valid_hashmap_put;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- m = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ m = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
valid_hashmap_put = hashmap_put(m, "key 1", (void*) (const char *) "val 1");
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_se(valid_hashmap_put == 1);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -236,7 +236,7 @@ static void test_hashmap_remove_and_put(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int valid;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
char *r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- m = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ m = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_se(m);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
valid = hashmap_remove_and_put(m, "unvalid key", "new key", NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -261,9 +261,9 @@ static void test_hashmap_ensure_allocated(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Hashmap *m;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int valid_hashmap;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- m = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ m = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- valid_hashmap = hashmap_ensure_allocated(&m, string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ valid_hashmap = hashmap_ensure_allocated(&m, &string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_se(valid_hashmap == 0);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_se(m);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -282,7 +282,7 @@ static void test_hashmap_foreach_key(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
"key 3\0"
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
"key 4\0";
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- m = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ m = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
NULSTR_FOREACH(key, key_table)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
hashmap_put(m, key, (void*) (const char*) "my dummy val");
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -319,7 +319,7 @@ static void test_hashmap_foreach(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
val4 = strdup("my val4");
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_se(val4);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- m = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ m = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
hashmap_put(m, "Key 1", val1);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
hashmap_put(m, "Key 2", val2);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -358,7 +358,7 @@ static void test_hashmap_foreach_backwards(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
val4 = strdup("my val4");
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_se(val4);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- m = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ m = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
hashmap_put(m, "Key 1", val1);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
hashmap_put(m, "Key 2", val2);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
hashmap_put(m, "Key 3", val3);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -395,8 +395,8 @@ static void test_hashmap_merge(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
val4 = strdup("my val4");
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_se(val4);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- n = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- m = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ n = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ m = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
hashmap_put(m, "Key 1", val1);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
hashmap_put(m, "Key 2", val2);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -422,7 +422,7 @@ static void test_hashmap_contains(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
val1 = strdup("my val");
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_se(val1);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- m = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ m = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_se(!hashmap_contains(m, "Key 1"));
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
hashmap_put(m, "Key 1", val1);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -439,7 +439,7 @@ static void test_hashmap_isempty(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
val1 = strdup("my val");
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_se(val1);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- m = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ m = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_se(hashmap_isempty(m));
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
hashmap_put(m, "Key 1", val1);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -462,7 +462,7 @@ static void test_hashmap_size(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
val4 = strdup("my val");
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_se(val4);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- m = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ m = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
hashmap_put(m, "Key 1", val1);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
hashmap_put(m, "Key 2", val2);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -482,7 +482,7 @@ static void test_hashmap_get(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
val = strdup("my val");
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_se(val);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- m = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ m = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
hashmap_put(m, "Key 1", val);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -499,7 +499,7 @@ static void test_hashmap_many(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
#define N_ENTRIES 100000
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- assert_se(h = hashmap_new(NULL, NULL));
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ assert_se(h = hashmap_new(NULL));
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
for (i = 1; i < N_ENTRIES*3; i+=3) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_se(hashmap_put(h, UINT_TO_PTR(i), UINT_TO_PTR(i)) >= 0);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -520,7 +520,7 @@ static void test_hashmap_many(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
static void test_hashmap_first_key(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
_cleanup_hashmap_free_ Hashmap *m = NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- m = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ m = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_se(m);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_se(!hashmap_first_key(m));
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -535,7 +535,7 @@ static void test_hashmap_first_key(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
static void test_hashmap_last(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
_cleanup_hashmap_free_ Hashmap *m = NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- m = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ m = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_se(m);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_se(!hashmap_last(m));
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -550,7 +550,7 @@ static void test_hashmap_last(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
static void test_hashmap_steal_first_key(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
_cleanup_hashmap_free_ Hashmap *m = NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- m = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ m = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_se(m);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_se(!hashmap_steal_first_key(m));
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -563,7 +563,7 @@ static void test_hashmap_steal_first_key(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
static void test_hashmap_clear_free_free(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
_cleanup_hashmap_free_ Hashmap *m = NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- m = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ m = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_se(m);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_se(hashmap_put(m, strdup("key 1"), NULL) == 1);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/test/test-install.c b/src/test/test-install.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 099eb401d7..b0f77a18f3 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/test/test-install.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/test/test-install.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -51,7 +51,7 @@ int main(int argc, char* argv[]) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
UnitFileChange *changes = NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
unsigned n_changes = 0;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- h = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ h = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
r = unit_file_get_list(UNIT_FILE_SYSTEM, NULL, h);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_se(r == 0);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/test/test-prioq.c b/src/test/test-prioq.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index cdb1e4ad52..dfedc9b8dc 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/test/test-prioq.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/test/test-prioq.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -98,6 +98,11 @@ static unsigned long test_hash(const void *a, const uint8_t hash_key[HASH_KEY_SI
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return (unsigned long) u;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+static const struct hash_ops test_hash_ops = {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ .hash = test_hash,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ .compare = test_compare
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+};
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
static void test_struct(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Prioq *q;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Set *s;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -109,7 +114,7 @@ static void test_struct(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
q = prioq_new(test_compare);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_se(q);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- s = set_new(test_hash, test_compare);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ s = set_new(&test_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_se(s);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
for (i = 0; i < SET_SIZE; i++) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/test/test-unit-file.c b/src/test/test-unit-file.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 34865729f2..89f5bdd4ed 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/test/test-unit-file.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/test/test-unit-file.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -44,7 +44,7 @@ static int test_unit_file_get_set(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Iterator i;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
UnitFileList *p;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- h = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ h = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert(h);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
r = unit_file_get_list(UNIT_FILE_SYSTEM, NULL, h);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 3bab7ac137..f9830c431d 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/tmpfiles/tmpfiles.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/tmpfiles/tmpfiles.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -165,7 +165,7 @@ static void load_unix_sockets(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
/* We maintain a cache of the sockets we found in
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
* /proc/net/unix to speed things up a little. */
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- unix_sockets = set_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ unix_sockets = set_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!unix_sockets)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1608,8 +1608,8 @@ int main(int argc, char *argv[]) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
label_init(NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- items = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- globs = hashmap_new(string_hash_func, string_compare_func);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ items = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ globs = hashmap_new(&string_hash_ops);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (!items || !globs) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
r = log_oom();
|