machine-image: introduce image_hash_ops and use it
This commit is contained in:
@@ -70,6 +70,8 @@ static Image *image_free(Image *i) {
|
||||
}
|
||||
|
||||
DEFINE_TRIVIAL_REF_UNREF_FUNC(Image, image, image_free);
|
||||
DEFINE_HASH_OPS_WITH_VALUE_DESTRUCTOR(image_hash_ops, char, string_hash_func, string_compare_func,
|
||||
Image, image_unref);
|
||||
|
||||
static char **image_settings_path(Image *image) {
|
||||
_cleanup_strv_free_ char **l = NULL;
|
||||
|
||||
@@ -59,12 +59,7 @@ typedef struct Image {
|
||||
Image *image_unref(Image *i);
|
||||
Image *image_ref(Image *i);
|
||||
|
||||
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);
|
||||
|
||||
int image_find(ImageClass class, const char *name, Image **ret);
|
||||
int image_from_path(const char *path, Image **ret);
|
||||
@@ -113,3 +108,5 @@ static inline bool IMAGE_IS_HOST(const struct Image *i) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
extern const struct hash_ops image_hash_ops;
|
||||
|
||||
Reference in New Issue
Block a user