From: Yu Watanabe Date: Sat, 17 Aug 2024 03:36:18 +0000 (+0900) Subject: network/address-label: introduce custom hash_ops X-Git-Tag: v257-rc1~670^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c95fa6acb5af9b2c2fbf909ba9958a8ab503cbfa;p=thirdparty%2Fsystemd.git network/address-label: introduce custom hash_ops No functional change, just refactoring. --- diff --git a/src/network/networkd-address-label.c b/src/network/networkd-address-label.c index e91ce3d2fa4..3bd7d3c5aed 100644 --- a/src/network/networkd-address-label.c +++ b/src/network/networkd-address-label.c @@ -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; diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c index 5335376e152..94666c2bdd0 100644 --- a/src/network/networkd-network.c +++ b/src/network/networkd-network.c @@ -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);