mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 00:14:32 +09:00
network: use hash ops with destructor
This commit is contained in:
@@ -32,7 +32,7 @@ static int address_pool_new(
|
||||
.in_addr = *u,
|
||||
};
|
||||
|
||||
r = ordered_set_ensure_put(&m->address_pools, NULL, p);
|
||||
r = ordered_set_ensure_put(&m->address_pools, &trivial_hash_ops_free, p);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
||||
@@ -692,7 +692,7 @@ Manager* manager_free(Manager *m) {
|
||||
m->wiphy_by_name = hashmap_free(m->wiphy_by_name);
|
||||
m->wiphy_by_index = hashmap_free_with_destructor(m->wiphy_by_index, wiphy_free);
|
||||
|
||||
ordered_set_free_free(m->address_pools);
|
||||
ordered_set_free(m->address_pools);
|
||||
|
||||
hashmap_free(m->route_table_names_by_number);
|
||||
hashmap_free(m->route_table_numbers_by_name);
|
||||
|
||||
@@ -170,7 +170,7 @@ int network_verify(Network *network) {
|
||||
network->bond_name = mfree(network->bond_name);
|
||||
network->bridge_name = mfree(network->bridge_name);
|
||||
network->vrf_name = mfree(network->vrf_name);
|
||||
network->stacked_netdev_names = hashmap_free_free_key(network->stacked_netdev_names);
|
||||
network->stacked_netdev_names = hashmap_free(network->stacked_netdev_names);
|
||||
|
||||
if (network->bond) {
|
||||
/* Bonding slave does not support addressing. */
|
||||
@@ -818,7 +818,7 @@ static Network *network_free(Network *network) {
|
||||
free(network->bridge_name);
|
||||
free(network->bond_name);
|
||||
free(network->vrf_name);
|
||||
hashmap_free_free_key(network->stacked_netdev_names);
|
||||
hashmap_free(network->stacked_netdev_names);
|
||||
netdev_unref(network->bridge);
|
||||
netdev_unref(network->bond);
|
||||
netdev_unref(network->vrf);
|
||||
@@ -949,7 +949,7 @@ int config_parse_stacked_netdev(
|
||||
if (!name)
|
||||
return log_oom();
|
||||
|
||||
r = hashmap_ensure_put(h, &string_hash_ops, name, INT_TO_PTR(kind));
|
||||
r = hashmap_ensure_put(h, &string_hash_ops_free, name, INT_TO_PTR(kind));
|
||||
if (r == -ENOMEM)
|
||||
return log_oom();
|
||||
if (r < 0)
|
||||
|
||||
@@ -97,7 +97,7 @@ static NextHop* nexthop_free(NextHop *nexthop) {
|
||||
nexthop_detach_impl(nexthop);
|
||||
|
||||
config_section_free(nexthop->section);
|
||||
hashmap_free_free(nexthop->group);
|
||||
hashmap_free(nexthop->group);
|
||||
set_free(nexthop->nexthops);
|
||||
set_free(nexthop->routes);
|
||||
|
||||
@@ -271,7 +271,7 @@ static int nexthop_dup(const NextHop *src, NextHop **ret) {
|
||||
if (!g)
|
||||
return -ENOMEM;
|
||||
|
||||
r = hashmap_ensure_put(&dest->group, NULL, UINT32_TO_PTR(g->id), g);
|
||||
r = hashmap_ensure_put(&dest->group, &trivial_hash_ops_value_free, UINT32_TO_PTR(g->id), g);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (r > 0)
|
||||
@@ -1018,7 +1018,7 @@ void link_forget_nexthops(Link *link) {
|
||||
}
|
||||
|
||||
static int nexthop_update_group(NextHop *nexthop, sd_netlink_message *message) {
|
||||
_cleanup_hashmap_free_free_ Hashmap *h = NULL;
|
||||
_cleanup_hashmap_free_ Hashmap *h = NULL;
|
||||
_cleanup_free_ struct nexthop_grp *group = NULL;
|
||||
size_t size = 0, n_group;
|
||||
int r;
|
||||
@@ -1058,7 +1058,7 @@ static int nexthop_update_group(NextHop *nexthop, sd_netlink_message *message) {
|
||||
if (!nhg)
|
||||
return log_oom();
|
||||
|
||||
r = hashmap_ensure_put(&h, NULL, UINT32_TO_PTR(nhg->id), nhg);
|
||||
r = hashmap_ensure_put(&h, &trivial_hash_ops_value_free, UINT32_TO_PTR(nhg->id), nhg);
|
||||
if (r == -ENOMEM)
|
||||
return log_oom();
|
||||
if (r < 0) {
|
||||
@@ -1069,9 +1069,7 @@ static int nexthop_update_group(NextHop *nexthop, sd_netlink_message *message) {
|
||||
TAKE_PTR(nhg);
|
||||
}
|
||||
|
||||
hashmap_free_free(nexthop->group);
|
||||
nexthop->group = TAKE_PTR(h);
|
||||
|
||||
hashmap_free_and_replace(nexthop->group, h);
|
||||
nexthop_attach_to_group_members(nexthop);
|
||||
return 0;
|
||||
}
|
||||
@@ -1377,7 +1375,7 @@ static int config_parse_nexthop_group(
|
||||
int r;
|
||||
|
||||
if (isempty(rvalue)) {
|
||||
*group = hashmap_free_free(*group);
|
||||
*group = hashmap_free(*group);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1431,7 +1429,7 @@ static int config_parse_nexthop_group(
|
||||
continue;
|
||||
}
|
||||
|
||||
r = hashmap_ensure_put(group, NULL, UINT32_TO_PTR(nhg->id), nhg);
|
||||
r = hashmap_ensure_put(group, &trivial_hash_ops_value_free, UINT32_TO_PTR(nhg->id), nhg);
|
||||
if (r == -ENOMEM)
|
||||
return log_oom();
|
||||
if (r == -EEXIST) {
|
||||
|
||||
Reference in New Issue
Block a user