@@ -46,11 +46,21 @@ static GenericNetlinkFamily *genl_family_free(GenericNetlinkFamily *f) {
4646
4747DEFINE_TRIVIAL_CLEANUP_FUNC (GenericNetlinkFamily * , genl_family_free );
4848
49+ DEFINE_PRIVATE_HASH_OPS_WITH_VALUE_DESTRUCTOR (
50+ genl_family_hash_ops_by_name ,
51+ char , string_hash_func , string_compare_func ,
52+ GenericNetlinkFamily , genl_family_free );
53+
54+ DEFINE_PRIVATE_HASH_OPS_WITH_VALUE_DESTRUCTOR (
55+ genl_family_hash_ops_by_id ,
56+ void , trivial_hash_func , trivial_compare_func ,
57+ GenericNetlinkFamily , genl_family_free );
58+
4959void genl_clear_family (sd_netlink * nl ) {
5060 assert (nl );
5161
52- nl -> genl_family_by_name = hashmap_free_with_destructor (nl -> genl_family_by_name , genl_family_free );
53- nl -> genl_family_by_id = hashmap_free_with_destructor (nl -> genl_family_by_id , genl_family_free );
62+ nl -> genl_family_by_name = hashmap_free (nl -> genl_family_by_name );
63+ nl -> genl_family_by_id = hashmap_free (nl -> genl_family_by_id );
5464}
5565
5666static int genl_family_new_unsupported (
@@ -80,7 +90,7 @@ static int genl_family_new_unsupported(
8090 if (!f -> name )
8191 return - ENOMEM ;
8292
83- r = hashmap_ensure_put (& nl -> genl_family_by_name , & string_hash_ops , f -> name , f );
93+ r = hashmap_ensure_put (& nl -> genl_family_by_name , & genl_family_hash_ops_by_name , f -> name , f );
8494 if (r < 0 )
8595 return r ;
8696
@@ -190,11 +200,11 @@ static int genl_family_new(
190200 return r ;
191201 }
192202
193- r = hashmap_ensure_put (& nl -> genl_family_by_id , NULL , UINT_TO_PTR (f -> id ), f );
203+ r = hashmap_ensure_put (& nl -> genl_family_by_id , & genl_family_hash_ops_by_id , UINT_TO_PTR (f -> id ), f );
194204 if (r < 0 )
195205 return r ;
196206
197- r = hashmap_ensure_put (& nl -> genl_family_by_name , & string_hash_ops , f -> name , f );
207+ r = hashmap_ensure_put (& nl -> genl_family_by_name , & genl_family_hash_ops_by_name , f -> name , f );
198208 if (r < 0 ) {
199209 hashmap_remove (nl -> genl_family_by_id , UINT_TO_PTR (f -> id ));
200210 return r ;
0 commit comments