m->tuntap_fds_by_name = hashmap_free(m->tuntap_fds_by_name);
m->wiphy_by_name = hashmap_free(m->wiphy_by_name);
- m->wiphy_by_index = hashmap_free_with_destructor(m->wiphy_by_index, wiphy_free);
+ m->wiphy_by_index = hashmap_free(m->wiphy_by_index);
ordered_set_free(m->address_pools);
#include "udev-util.h"
#include "wifi-util.h"
-Wiphy *wiphy_free(Wiphy *w) {
+static Wiphy* wiphy_free(Wiphy *w) {
if (!w)
return NULL;
return mfree(w);
}
+DEFINE_TRIVIAL_CLEANUP_FUNC(Wiphy*, wiphy_free);
+
+DEFINE_PRIVATE_HASH_OPS_WITH_VALUE_DESTRUCTOR(
+ wiphy_hash_ops,
+ void, trivial_hash_func, trivial_compare_func,
+ Wiphy, wiphy_free);
+
static int wiphy_new(Manager *manager, sd_netlink_message *message, Wiphy **ret) {
_cleanup_(wiphy_freep) Wiphy *w = NULL;
_cleanup_free_ char *name = NULL;
.name = TAKE_PTR(name),
};
- r = hashmap_ensure_put(&manager->wiphy_by_index, NULL, UINT32_TO_PTR(w->index), w);
+ r = hashmap_ensure_put(&manager->wiphy_by_index, &wiphy_hash_ops, UINT32_TO_PTR(w->index), w);
if (r < 0)
return r;
RFKillState rfkill_state;
} Wiphy;
-Wiphy *wiphy_free(Wiphy *w);
-DEFINE_TRIVIAL_CLEANUP_FUNC(Wiphy*, wiphy_free);
-
int wiphy_get_by_index(Manager *manager, uint32_t index, Wiphy **ret);
int wiphy_get_by_name(Manager *manager, const char *name, Wiphy **ret);