udev: use hashmap_clear_free_key() and hashmap_free_free_key()

This commit is contained in:
Yu Watanabe
2018-11-26 03:32:20 +09:00
parent 67818055b7
commit e924c60f69
2 changed files with 3 additions and 11 deletions

View File

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

View File

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