]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
machine-image: convert image_hashmap_free() to an static inline helper
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 28 Nov 2017 11:36:35 +0000 (12:36 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 28 Nov 2017 20:30:43 +0000 (21:30 +0100)
src/shared/machine-image.c
src/shared/machine-image.h

index 5b6260cbb8a4588b4fe94fbf2011b25543a802a0..66eefb3036628ecb02f7168f597e50ccfbe19e89 100644 (file)
@@ -457,15 +457,6 @@ int image_discover(Hashmap *h) {
         return 0;
 }
 
-void image_hashmap_free(Hashmap *map) {
-        Image *i;
-
-        while ((i = hashmap_steal_first(map)))
-                image_unref(i);
-
-        hashmap_free(map);
-}
-
 int image_remove(Image *i) {
         _cleanup_release_lock_file_ LockFile global_lock = LOCK_FILE_INIT, local_lock = LOCK_FILE_INIT;
         _cleanup_strv_free_ char **settings = NULL;
index 9573000a5ac95d52228646384e40ae91d9eef483..3df9a29a2428668c0a0b0f5b82651674496adcd6 100644 (file)
@@ -64,7 +64,9 @@ typedef struct Image {
 } Image;
 
 Image *image_unref(Image *i);
-void image_hashmap_free(Hashmap *map);
+static inline Hashmap* image_hashmap_free(Hashmap *map) {
+        return hashmap_free_with_destructor(map, image_unref);
+}
 
 DEFINE_TRIVIAL_CLEANUP_FUNC(Image*, image_unref);
 DEFINE_TRIVIAL_CLEANUP_FUNC(Hashmap*, image_hashmap_free);