network/address-label: introduce custom hash_ops

No functional change, just refactoring.
This commit is contained in:
Yu Watanabe
2024-08-20 20:48:48 +09:00
parent 61242b1f0f
commit c95fa6acb5
2 changed files with 10 additions and 2 deletions
+9 -1
View 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;
+1 -1
View 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);