]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-bus: introduce track_item_hash_ops and use it
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 25 Nov 2018 15:04:46 +0000 (00:04 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 2 Dec 2018 11:18:49 +0000 (12:18 +0100)
src/libsystemd/sd-bus/bus-track.c

index 4c959cc29ccfbe88cb10f3c30f3678ae7a75ed22..efbd3ed5f016e9a53bd2c3a855c6513cb2a963e8 100644 (file)
@@ -50,6 +50,8 @@ static struct track_item* track_item_free(struct track_item *i) {
 }
 
 DEFINE_TRIVIAL_CLEANUP_FUNC(struct track_item*, track_item_free);
+DEFINE_PRIVATE_HASH_OPS_WITH_VALUE_DESTRUCTOR(track_item_hash_ops, char, string_hash_func, string_compare_func,
+                                              struct track_item, track_item_free);
 
 static void bus_track_add_to_queue(sd_bus_track *track) {
         assert(track);
@@ -150,7 +152,7 @@ static sd_bus_track *track_free(sd_bus_track *track) {
                 LIST_REMOVE(tracks, track->bus->tracks, track);
 
         bus_track_remove_from_queue(track);
-        track->names = hashmap_free_with_destructor(track->names, track_item_free);
+        track->names = hashmap_free(track->names);
         track->bus = sd_bus_unref(track->bus);
 
         if (track->destroy_callback)
@@ -201,7 +203,7 @@ _public_ int sd_bus_track_add_name(sd_bus_track *track, const char *name) {
                 return 0;
         }
 
-        r = hashmap_ensure_allocated(&track->names, &string_hash_ops);
+        r = hashmap_ensure_allocated(&track->names, &track_item_hash_ops);
         if (r < 0)
                 return r;
 
@@ -397,7 +399,7 @@ void bus_track_close(sd_bus_track *track) {
                 return;
 
         /* Let's flush out all names */
-        hashmap_clear_with_destructor(track->names, track_item_free);
+        hashmap_clear(track->names);
 
         /* Invoke handler */
         if (track->handler)