diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2018-11-25 19:32:20 +0100 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2018-12-02 12:18:54 +0100 |
commit | e924c60f69506620f69e4b0cb76b86fa8040107e (patch) | |
tree | 725b4c75a62adc9d87930a6e2b1692dba8648166 /src | |
parent | portable: introduce portable_metadata_hash_ops and use it (diff) | |
download | systemd-e924c60f69506620f69e4b0cb76b86fa8040107e.tar.xz systemd-e924c60f69506620f69e4b0cb76b86fa8040107e.zip |
udev: use hashmap_clear_free_key() and hashmap_free_free_key()
Diffstat (limited to 'src')
-rw-r--r-- | src/udev/udev-event.c | 6 | ||||
-rw-r--r-- | src/udev/udev-rules.c | 8 |
2 files changed, 3 insertions, 11 deletions
diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c index 840d20beac..3782d892c2 100644 --- a/src/udev/udev-event.c +++ b/src/udev/udev-event.c @@ -64,17 +64,13 @@ struct udev_event *udev_event_new(sd_device *dev, usec_t exec_delay_usec, sd_net } struct udev_event *udev_event_free(struct udev_event *event) { - void *p; - if (!event) return NULL; sd_device_unref(event->dev); sd_device_unref(event->dev_db_clone); sd_netlink_unref(event->rtnl); - while ((p = hashmap_steal_first_key(event->run_list))) - free(p); - hashmap_free(event->run_list); + hashmap_free_free_key(event->run_list); hashmap_free_free_free(event->seclabel_list); free(event->program_result); free(event->name); diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c index f6f640a216..a9fa04dbf0 100644 --- a/src/udev/udev-rules.c +++ b/src/udev/udev-rules.c @@ -2407,12 +2407,8 @@ int udev_rules_apply_to_event( case TK_A_RUN_PROGRAM: { _cleanup_free_ char *cmd = NULL; - if (IN_SET(cur->key.op, OP_ASSIGN, OP_ASSIGN_FINAL)) { - void *p; - - while ((p = hashmap_steal_first_key(event->run_list))) - free(p); - } + if (IN_SET(cur->key.op, OP_ASSIGN, OP_ASSIGN_FINAL)) + hashmap_clear_free_key(event->run_list); r = hashmap_ensure_allocated(&event->run_list, NULL); if (r < 0) |