diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2020-04-29 08:47:51 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2020-05-06 16:54:06 +0200 |
commit | be32732168e07b7d52ec77fa67cf93a80a9a8293 (patch) | |
tree | 0feb0a006050702078fd41b5fea2eee9c4d00b08 /src/shared/bus-wait-for-jobs.c | |
parent | 0894f08bf14b09ef0436ed11268d43dbcdd88ee7 (diff) | |
download | systemd-be32732168e07b7d52ec77fa67cf93a80a9a8293.tar.gz |
basic/set: let set_put_strdup() create the set with string hash ops
If we're using a set with _put_strdup(), most of the time we want to use
string hash ops on the set, and free the strings when done. This defines
the appropriate a new string_hash_ops_free structure to automatically free
the keys when removing the set, and makes set_put_strdup() and set_put_strdupv()
instantiate the set with those hash ops.
hashmap_put_strdup() was already doing something similar.
(It is OK to instantiate the set earlier, possibly with a different hash ops
structure. set_put_strdup() will then use the existing set. It is also OK
to call set_free_free() instead of set_free() on a set with
string_hash_ops_free, the effect is the same, we're just overriding the
override of the cleanup function.)
No functional change intended.
Diffstat (limited to 'src/shared/bus-wait-for-jobs.c')
-rw-r--r-- | src/shared/bus-wait-for-jobs.c | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/src/shared/bus-wait-for-jobs.c b/src/shared/bus-wait-for-jobs.c index 4e6b862d5e..eb33ba2340 100644 --- a/src/shared/bus-wait-for-jobs.c +++ b/src/shared/bus-wait-for-jobs.c @@ -65,7 +65,7 @@ void bus_wait_for_jobs_free(BusWaitForJobs *d) { if (!d) return; - set_free_free(d->jobs); + set_free(d->jobs); sd_bus_slot_unref(d->slot_disconnected); sd_bus_slot_unref(d->slot_job_removed); @@ -315,15 +315,9 @@ int bus_wait_for_jobs(BusWaitForJobs *d, bool quiet, const char* const* extra_ar } int bus_wait_for_jobs_add(BusWaitForJobs *d, const char *path) { - int r; - assert(d); - r = set_ensure_allocated(&d->jobs, &string_hash_ops); - if (r < 0) - return r; - - return set_put_strdup(d->jobs, path); + return set_put_strdup(&d->jobs, path); } int bus_wait_for_jobs_one(BusWaitForJobs *d, const char *path, bool quiet) { |