summaryrefslogtreecommitdiff
path: root/src/machine
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2018-11-28 22:54:44 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2018-12-02 12:18:54 +0100
commitb07ec5a173f285c35661150764562fb78bb6fadd (patch)
tree28fe94c8ff17b893ea5ddd7b0addb4e9b82ae471 /src/machine
parent87938c3bea13fe1a237303fd15c69a0249a96c18 (diff)
downloadsystemd-b07ec5a173f285c35661150764562fb78bb6fadd.tar.gz
systemd-b07ec5a173f285c35661150764562fb78bb6fadd.tar.bz2
systemd-b07ec5a173f285c35661150764562fb78bb6fadd.zip
machine-image: introduce image_hash_ops and use it
Diffstat (limited to 'src/machine')
-rw-r--r--src/machine/image-dbus.c8
-rw-r--r--src/machine/machined-dbus.c8
-rw-r--r--src/machine/machined.c3
3 files changed, 9 insertions, 10 deletions
diff --git a/src/machine/image-dbus.c b/src/machine/image-dbus.c
index 89df274544..a311ed9077 100644
--- a/src/machine/image-dbus.c
+++ b/src/machine/image-dbus.c
@@ -382,7 +382,7 @@ static int image_flush_cache(sd_event_source *s, void *userdata) {
assert(s);
assert(m);
- hashmap_clear_with_destructor(m->image_cache, image_unref);
+ hashmap_clear(m->image_cache);
return 0;
}
@@ -412,7 +412,7 @@ int image_object_find(sd_bus *bus, const char *path, const char *interface, void
return 1;
}
- r = hashmap_ensure_allocated(&m->image_cache, &string_hash_ops);
+ r = hashmap_ensure_allocated(&m->image_cache, &image_hash_ops);
if (r < 0)
return r;
@@ -461,7 +461,7 @@ char *image_bus_path(const char *name) {
}
int image_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error) {
- _cleanup_(image_hashmap_freep) Hashmap *images = NULL;
+ _cleanup_hashmap_free_ Hashmap *images = NULL;
_cleanup_strv_free_ char **l = NULL;
Image *image;
Iterator i;
@@ -471,7 +471,7 @@ int image_node_enumerator(sd_bus *bus, const char *path, void *userdata, char **
assert(path);
assert(nodes);
- images = hashmap_new(&string_hash_ops);
+ images = hashmap_new(&image_hash_ops);
if (!images)
return -ENOMEM;
diff --git a/src/machine/machined-dbus.c b/src/machine/machined-dbus.c
index 453ca30b64..ef1958d8b0 100644
--- a/src/machine/machined-dbus.c
+++ b/src/machine/machined-dbus.c
@@ -463,7 +463,7 @@ static int method_get_machine_os_release(sd_bus_message *message, void *userdata
static int method_list_images(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
- _cleanup_(image_hashmap_freep) Hashmap *images = NULL;
+ _cleanup_hashmap_free_ Hashmap *images = NULL;
Manager *m = userdata;
Image *image;
Iterator i;
@@ -472,7 +472,7 @@ static int method_list_images(sd_bus_message *message, void *userdata, sd_bus_er
assert(message);
assert(m);
- images = hashmap_new(&string_hash_ops);
+ images = hashmap_new(&image_hash_ops);
if (!images)
return -ENOMEM;
@@ -740,7 +740,7 @@ static int method_clean_pool(sd_bus_message *message, void *userdata, sd_bus_err
if (r < 0)
return sd_bus_error_set_errnof(error, r, "Failed to fork(): %m");
if (r == 0) {
- _cleanup_(image_hashmap_freep) Hashmap *images = NULL;
+ _cleanup_hashmap_free_ Hashmap *images = NULL;
bool success = true;
Image *image;
Iterator i;
@@ -748,7 +748,7 @@ static int method_clean_pool(sd_bus_message *message, void *userdata, sd_bus_err
errno_pipe_fd[0] = safe_close(errno_pipe_fd[0]);
- images = hashmap_new(&string_hash_ops);
+ images = hashmap_new(&image_hash_ops);
if (!images) {
r = -ENOMEM;
goto child_fail;
diff --git a/src/machine/machined.c b/src/machine/machined.c
index 22eb030dee..6742722d0d 100644
--- a/src/machine/machined.c
+++ b/src/machine/machined.c
@@ -77,8 +77,7 @@ static Manager* manager_unref(Manager *m) {
hashmap_free(m->machines);
hashmap_free(m->machine_units);
hashmap_free(m->machine_leaders);
-
- hashmap_free_with_destructor(m->image_cache, image_unref);
+ hashmap_free(m->image_cache);
sd_event_source_unref(m->image_cache_defer_event);