From: Zbigniew Jędrzejewski-Szmek Date: Tue, 28 Nov 2017 11:36:35 +0000 (+0100) Subject: machine-image: convert image_hashmap_free() to an static inline helper X-Git-Tag: v236~99^2~8 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e85b096b439306b95869c3ae10b6e6761cbf6eca;p=thirdparty%2Fsystemd.git machine-image: convert image_hashmap_free() to an static inline helper --- diff --git a/src/shared/machine-image.c b/src/shared/machine-image.c index 5b6260cbb8a..66eefb30366 100644 --- a/src/shared/machine-image.c +++ b/src/shared/machine-image.c @@ -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; diff --git a/src/shared/machine-image.h b/src/shared/machine-image.h index 9573000a5ac..3df9a29a242 100644 --- a/src/shared/machine-image.h +++ b/src/shared/machine-image.h @@ -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);