network: split link_free() into two parts

This commit is contained in:
Yu Watanabe 2019-06-21 12:06:56 +09:00
parent a1d736e25c
commit 1a6bb31fae
1 changed files with 20 additions and 15 deletions

View File

@ -661,6 +661,25 @@ void link_dns_settings_clear(Link *link) {
link->dnssec_negative_trust_anchors = set_free_free(link->dnssec_negative_trust_anchors);
}
static void link_free_engines(Link *link) {
if (!link)
return;
link->dhcp_server = sd_dhcp_server_unref(link->dhcp_server);
link->dhcp_client = sd_dhcp_client_unref(link->dhcp_client);
link->dhcp_lease = sd_dhcp_lease_unref(link->dhcp_lease);
link->dhcp_routes = set_free(link->dhcp_routes);
link->lldp = sd_lldp_unref(link->lldp);
ndisc_flush(link);
link->ipv4ll = sd_ipv4ll_unref(link->ipv4ll);
link->dhcp6_client = sd_dhcp6_client_unref(link->dhcp6_client);
link->ndisc = sd_ndisc_unref(link->ndisc);
link->radv = sd_radv_unref(link->radv);
}
static Link *link_free(Link *link) {
Address *address;
@ -686,25 +705,11 @@ static Link *link_free(Link *link) {
address_free(address);
}
sd_dhcp_server_unref(link->dhcp_server);
sd_dhcp_client_unref(link->dhcp_client);
sd_dhcp_lease_unref(link->dhcp_lease);
set_free(link->dhcp_routes);
link_lldp_emit_stop(link);
link_free_engines(link);
free(link->lease_file);
sd_lldp_unref(link->lldp);
free(link->lldp_file);
ndisc_flush(link);
sd_ipv4ll_unref(link->ipv4ll);
sd_dhcp6_client_unref(link->dhcp6_client);
sd_ndisc_unref(link->ndisc);
sd_radv_unref(link->radv);
free(link->ifname);
free(link->kind);