summaryrefslogtreecommitdiff
path: root/src/cryptsetup/cryptsetup-generator.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-11-28 12:37:51 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-11-28 21:34:41 +0100
commit6dd1c3683949892d1d7d067efc575f0aa33ea6b3 (patch)
tree2cae8ce92ca5ff11e952ca78df48803d0670629c /src/cryptsetup/cryptsetup-generator.c
parent39ab16e3970cfce48a9b72125cd9be7afe1e3a8e (diff)
downloadsystemd-6dd1c3683949892d1d7d067efc575f0aa33ea6b3.tar.gz
cryptsetup-generator: add helper function and use hashmap_free_with_destructor
Diffstat (limited to 'src/cryptsetup/cryptsetup-generator.c')
-rw-r--r--src/cryptsetup/cryptsetup-generator.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/cryptsetup/cryptsetup-generator.c b/src/cryptsetup/cryptsetup-generator.c
index 3f7222a8aa..d0be412625 100644
--- a/src/cryptsetup/cryptsetup-generator.c
+++ b/src/cryptsetup/cryptsetup-generator.c
@@ -219,18 +219,12 @@ static int create_disk(
return 0;
}
-static void free_arg_disks(void) {
- crypto_device *d;
-
- while ((d = hashmap_steal_first(arg_disks))) {
- free(d->uuid);
- free(d->keyfile);
- free(d->name);
- free(d->options);
- free(d);
- }
-
- hashmap_free(arg_disks);
+static void crypt_device_free(crypto_device *d) {
+ free(d->uuid);
+ free(d->keyfile);
+ free(d->name);
+ free(d->options);
+ free(d);
}
static crypto_device *get_crypto_device(const char *uuid) {
@@ -492,7 +486,7 @@ int main(int argc, char *argv[]) {
r = 0;
finish:
- free_arg_disks();
+ hashmap_free_with_destructor(arg_disks, crypt_device_free);
free(arg_default_options);
free(arg_default_keyfile);