]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network/address-label: introduce custom hash_ops
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 17 Aug 2024 03:36:18 +0000 (12:36 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 20 Aug 2024 11:48:48 +0000 (20:48 +0900)
No functional change, just refactoring.

src/network/networkd-address-label.c
src/network/networkd-network.c

index e91ce3d2fa46f1c8e9b0778793e197a2c08b0d2c..3bd7d3c5aed1fc0f2631efd514390d7b0da07dde 100644 (file)
@@ -28,6 +28,14 @@ AddressLabel *address_label_free(AddressLabel *label) {
 
 DEFINE_SECTION_CLEANUP_FUNCTIONS(AddressLabel, address_label_free);
 
+DEFINE_PRIVATE_HASH_OPS_WITH_VALUE_DESTRUCTOR(
+        address_label_section_hash_ops,
+        ConfigSection,
+        config_section_hash_func,
+        config_section_compare_func,
+        AddressLabel,
+        address_label_free);
+
 static int address_label_new_static(Network *network, const char *filename, unsigned section_line, AddressLabel **ret) {
         _cleanup_(config_section_freep) ConfigSection *n = NULL;
         _cleanup_(address_label_freep) AddressLabel *label = NULL;
@@ -58,7 +66,7 @@ static int address_label_new_static(Network *network, const char *filename, unsi
                 .label = UINT32_MAX,
         };
 
-        r = hashmap_ensure_put(&network->address_labels_by_section, &config_section_hash_ops, label->section, label);
+        r = hashmap_ensure_put(&network->address_labels_by_section, &address_label_section_hash_ops, label->section, label);
         if (r < 0)
                 return r;
 
index 5335376e152b936a848d7dc1b4d2a7ba37880ab5..94666c2bdd03edd8ed67ee6171c4c6bc99d1aacd 100644 (file)
@@ -794,7 +794,7 @@ static Network *network_free(Network *network) {
         hashmap_free_with_destructor(network->bridge_fdb_entries_by_section, bridge_fdb_free);
         hashmap_free_with_destructor(network->bridge_mdb_entries_by_section, bridge_mdb_free);
         ordered_hashmap_free(network->neighbors_by_section);
-        hashmap_free_with_destructor(network->address_labels_by_section, address_label_free);
+        hashmap_free(network->address_labels_by_section);
         hashmap_free_with_destructor(network->prefixes_by_section, prefix_free);
         hashmap_free_with_destructor(network->route_prefixes_by_section, route_prefix_free);
         hashmap_free_with_destructor(network->pref64_prefixes_by_section, prefix64_free);