1
0
mirror of https://github.com/systemd/systemd.git synced 2025-08-29 01:49:55 +03:00

cryptsetup-generator: add helper function and use hashmap_free_with_destructor

This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2017-11-28 12:37:51 +01:00
parent 39ab16e397
commit 6dd1c36839

View File

@ -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);