hashmap_free_with_destructor(network->pref64_prefixes_by_section, prefix64_free);
hashmap_free(network->rules_by_section);
hashmap_free_with_destructor(network->dhcp_static_leases_by_section, dhcp_static_lease_free);
- ordered_hashmap_free_with_destructor(network->sr_iov_by_section, sr_iov_free);
+ ordered_hashmap_free(network->sr_iov_by_section);
hashmap_free(network->qdiscs_by_section);
hashmap_free(network->tclasses_by_section);
#include "stdio-util.h"
#include "string-util.h"
+static SRIOV* sr_iov_free(SRIOV *sr_iov) {
+ if (!sr_iov)
+ return NULL;
+
+ if (sr_iov->sr_iov_by_section && sr_iov->section)
+ ordered_hashmap_remove(sr_iov->sr_iov_by_section, sr_iov->section);
+
+ config_section_free(sr_iov->section);
+
+ return mfree(sr_iov);
+}
+
+DEFINE_SECTION_CLEANUP_FUNCTIONS(SRIOV, sr_iov_free);
+
+DEFINE_PRIVATE_HASH_OPS_WITH_VALUE_DESTRUCTOR(
+ sr_iov_hash_ops_by_section,
+ ConfigSection, config_section_hash_func, config_section_compare_func,
+ SRIOV, sr_iov_free);
+
static int sr_iov_new(SRIOV **ret) {
SRIOV *sr_iov;
if (r < 0)
return r;
- r = ordered_hashmap_ensure_put(sr_iov_by_section, &config_section_hash_ops, n, sr_iov);
+ r = ordered_hashmap_ensure_put(sr_iov_by_section, &sr_iov_hash_ops_by_section, n, sr_iov);
if (r < 0)
return r;
return 0;
}
-SRIOV *sr_iov_free(SRIOV *sr_iov) {
- if (!sr_iov)
- return NULL;
-
- if (sr_iov->sr_iov_by_section && sr_iov->section)
- ordered_hashmap_remove(sr_iov->sr_iov_by_section, sr_iov->section);
-
- config_section_free(sr_iov->section);
-
- return mfree(sr_iov);
-}
-
void sr_iov_hash_func(const SRIOV *sr_iov, struct siphash *state) {
assert(sr_iov);
assert(state);
struct ether_addr mac;
} SRIOV;
-SRIOV *sr_iov_free(SRIOV *sr_iov);
void sr_iov_hash_func(const SRIOV *sr_iov, struct siphash *state);
int sr_iov_compare_func(const SRIOV *s1, const SRIOV *s2);
int sr_iov_set_netlink_message(SRIOV *sr_iov, sd_netlink_message *req);
int sr_iov_set_num_vfs(sd_device *device, uint32_t num_vfs, OrderedHashmap *sr_iov_by_section);
int sr_iov_drop_invalid_sections(uint32_t num_vfs, OrderedHashmap *sr_iov_by_section);
-DEFINE_SECTION_CLEANUP_FUNCTIONS(SRIOV, sr_iov_free);
-
CONFIG_PARSER_PROTOTYPE(config_parse_sr_iov_uint32);
CONFIG_PARSER_PROTOTYPE(config_parse_sr_iov_boolean);
CONFIG_PARSER_PROTOTYPE(config_parse_sr_iov_link_state);
erase_and_free(config->wol_password);
cpu_set_free(config->rps_cpu_mask);
- ordered_hashmap_free_with_destructor(config->sr_iov_by_section, sr_iov_free);
+ ordered_hashmap_free(config->sr_iov_by_section);
return mfree(config);
}