]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: set key destructor in several hash_ops
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 21 Jul 2020 23:22:55 +0000 (08:22 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 28 Jul 2020 17:05:05 +0000 (02:05 +0900)
src/network/networkd-address.c
src/network/networkd-link.c
src/network/networkd-manager.c
src/network/networkd-neighbor.c
src/network/networkd-routing-policy-rule.c
src/network/test-routing-policy-rule.c

index 216c425b3432cfa3e40848b519ca748591c9032e..96782d608a58538e37a22c571bb0474c19e9d9e2 100644 (file)
@@ -205,7 +205,7 @@ static int address_compare_func(const Address *a1, const Address *a2) {
         }
 }
 
-DEFINE_HASH_OPS(address_hash_ops, Address, address_hash_func, address_compare_func);
+DEFINE_HASH_OPS_WITH_KEY_DESTRUCTOR(address_hash_ops, Address, address_hash_func, address_compare_func, address_free);
 
 bool address_equal(Address *a1, Address *a2) {
         if (a1 == a2)
index 15cfe39553753f735926cb2853bb14fe5737421f..0acd35444e986243012ca6cb347bcd32b6bced1d 100644 (file)
@@ -711,17 +711,17 @@ static Link *link_free(Link *link) {
         link_ntp_settings_clear(link);
         link_dns_settings_clear(link);
 
-        link->routes = set_free_with_destructor(link->routes, route_free);
-        link->routes_foreign = set_free_with_destructor(link->routes_foreign, route_free);
+        link->routes = set_free(link->routes);
+        link->routes_foreign = set_free(link->routes_foreign);
 
-        link->nexthops = set_free_with_destructor(link->nexthops, nexthop_free);
-        link->nexthops_foreign = set_free_with_destructor(link->nexthops_foreign, nexthop_free);
+        link->nexthops = set_free(link->nexthops);
+        link->nexthops_foreign = set_free(link->nexthops_foreign);
 
-        link->neighbors = set_free_with_destructor(link->neighbors, neighbor_free);
-        link->neighbors_foreign = set_free_with_destructor(link->neighbors_foreign, neighbor_free);
+        link->neighbors = set_free(link->neighbors);
+        link->neighbors_foreign = set_free(link->neighbors_foreign);
 
-        link->addresses = set_free_with_destructor(link->addresses, address_free);
-        link->addresses_foreign = set_free_with_destructor(link->addresses_foreign, address_free);
+        link->addresses = set_free(link->addresses);
+        link->addresses_foreign = set_free(link->addresses_foreign);
 
         while ((address = link->pool_addresses)) {
                 LIST_REMOVE(addresses, link->pool_addresses, address);
index f2c956c70fab58712500fa11874cafb97b460ccd..a67ff250ee51f6a488e91498dea19ff2cac5087f 100644 (file)
@@ -1859,9 +1859,9 @@ void manager_free(Manager *m) {
 
         /* routing_policy_rule_free() access m->rules and m->rules_foreign.
          * So, it is necessary to set NULL after the sets are freed. */
-        m->rules = set_free_with_destructor(m->rules, routing_policy_rule_free);
-        m->rules_foreign = set_free_with_destructor(m->rules_foreign, routing_policy_rule_free);
-        set_free_with_destructor(m->rules_saved, routing_policy_rule_free);
+        m->rules = set_free(m->rules);
+        m->rules_foreign = set_free(m->rules_foreign);
+        set_free(m->rules_saved);
 
         sd_netlink_unref(m->rtnl);
         sd_netlink_unref(m->genl);
index 0e97b225c4547ddff63dd5e2864db39a26767fe7..09ddb9c8a56b809db09ba702d404efc5cac8cfed 100644 (file)
@@ -247,7 +247,7 @@ static int neighbor_compare_func(const Neighbor *a, const Neighbor *b) {
         return memcmp(&a->lladdr, &b->lladdr, a->lladdr_size);
 }
 
-DEFINE_PRIVATE_HASH_OPS(neighbor_hash_ops, Neighbor, neighbor_hash_func, neighbor_compare_func);
+DEFINE_PRIVATE_HASH_OPS_WITH_KEY_DESTRUCTOR(neighbor_hash_ops, Neighbor, neighbor_hash_func, neighbor_compare_func, neighbor_free);
 
 int neighbor_get(Link *link, int family, const union in_addr_union *addr, const union lladdr_union *lladdr, size_t lladdr_size, Neighbor **ret) {
         Neighbor neighbor, *existing;
index e06d4b070a1c9988f85db50bc8fe24b9f3879907..36dad527d0969e501c03fc6a1b3debb9543d4606 100644 (file)
@@ -227,7 +227,12 @@ static int routing_policy_rule_compare_func(const RoutingPolicyRule *a, const Ro
         }
 }
 
-DEFINE_PRIVATE_HASH_OPS(routing_policy_rule_hash_ops, RoutingPolicyRule, routing_policy_rule_hash_func, routing_policy_rule_compare_func);
+DEFINE_PRIVATE_HASH_OPS_WITH_KEY_DESTRUCTOR(
+                routing_policy_rule_hash_ops,
+                RoutingPolicyRule,
+                routing_policy_rule_hash_func,
+                routing_policy_rule_compare_func,
+                routing_policy_rule_free);
 
 int routing_policy_rule_get(Manager *m, RoutingPolicyRule *rule, RoutingPolicyRule **ret) {
 
index d441099b5a5c07262820d5ea5846d996027d00f2..d84d746c3fa8e2dd423b159bb716b4546437bd86 100644 (file)
@@ -53,7 +53,7 @@ static void test_rule_serialization(const char *title, const char *ruleset, cons
         log_info("$ %s", cmd);
         assert_se(system(cmd) == 0);
 
-        set_free_with_destructor(rules, routing_policy_rule_free);
+        set_free(rules);
 }
 
 int main(int argc, char **argv) {