From 956833b4170dcc957befb9009f5ea4a6dbd05e87 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 18 Dec 2018 15:03:50 +0900 Subject: [PATCH] udevd: provide worker_hash_ops and drop manager_workers_free() --- src/udev/udevd.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/src/udev/udevd.c b/src/udev/udevd.c index 24f4824..837e13e 100644 --- a/src/udev/udevd.c +++ b/src/udev/udevd.c @@ -187,18 +187,7 @@ static void worker_free(struct worker *worker) { } DEFINE_TRIVIAL_CLEANUP_FUNC(struct worker *, worker_free); - -static void manager_workers_free(Manager *manager) { - struct worker *worker; - Iterator i; - - assert(manager); - - HASHMAP_FOREACH(worker, manager->workers, i) - worker_free(worker); - - manager->workers = hashmap_free(manager->workers); -} +DEFINE_PRIVATE_HASH_OPS_WITH_VALUE_DESTRUCTOR(worker_hash_op, void, trivial_hash_func, trivial_compare_func, struct worker, worker_free); static int worker_new(struct worker **ret, Manager *manager, sd_device_monitor *worker_monitor, pid_t pid) { _cleanup_(worker_freep) struct worker *worker = NULL; @@ -222,7 +211,7 @@ static int worker_new(struct worker **ret, Manager *manager, sd_device_monitor * .pid = pid, }; - r = hashmap_ensure_allocated(&manager->workers, NULL); + r = hashmap_ensure_allocated(&manager->workers, &worker_hash_op); if (r < 0) return r; @@ -296,7 +285,7 @@ static void manager_clear_for_worker(Manager *manager) { manager->event = sd_event_unref(manager->event); - manager_workers_free(manager); + manager->workers = hashmap_free(manager->workers); event_queue_cleanup(manager, EVENT_UNDEF); manager->monitor = sd_device_monitor_unref(manager->monitor); -- 2.7.4