diff --git a/src/dns/nm-dns-manager.c b/src/dns/nm-dns-manager.c index a88e64428c..09a9e7125d 100644 --- a/src/dns/nm-dns-manager.c +++ b/src/dns/nm-dns-manager.c @@ -1671,7 +1671,7 @@ nm_dns_manager_set_ip_config (NMDnsManager *self, priv = NM_DNS_MANAGER_GET_PRIVATE (self); - data = g_hash_table_lookup (priv->configs, GINT_TO_POINTER (ifindex)); + data = g_hash_table_lookup (priv->configs, &ifindex); if (!data) ip_data = NULL; else @@ -1687,7 +1687,7 @@ nm_dns_manager_set_ip_config (NMDnsManager *self, /* deleting a config doesn't invalidate the configs' sort order. */ _ip_config_data_free (ip_data); if (c_list_is_empty (&data->data_lst_head)) - g_hash_table_remove (priv->configs, GINT_TO_POINTER (ifindex)); + g_hash_table_remove (priv->configs, &ifindex); goto changed; } @@ -1705,7 +1705,7 @@ nm_dns_manager_set_ip_config (NMDnsManager *self, .data_lst_head = C_LIST_INIT (data->data_lst_head), }; _ASSERT_config_data (data); - g_hash_table_insert (priv->configs, GINT_TO_POINTER (ifindex), data); + g_hash_table_add (priv->configs, data); } if (!ip_data) @@ -2348,8 +2348,11 @@ nm_dns_manager_init (NMDnsManager *self) priv->config = g_object_ref (nm_config_get ()); - priv->configs = g_hash_table_new_full (nm_direct_hash, NULL, - NULL, (GDestroyNotify) _config_data_free); + G_STATIC_ASSERT_EXPR (G_STRUCT_OFFSET (NMDnsConfigData, ifindex) == 0); + priv->configs = g_hash_table_new_full (nm_pint_hash, + nm_pint_equals, + (GDestroyNotify) _config_data_free, + NULL); /* Set the initial hash */ compute_hash (self, NULL, NM_DNS_MANAGER_GET_PRIVATE (self)->hash); diff --git a/src/dns/nm-dns-manager.h b/src/dns/nm-dns-manager.h index 2a0c9deee3..b60414566c 100644 --- a/src/dns/nm-dns-manager.h +++ b/src/dns/nm-dns-manager.h @@ -41,9 +41,9 @@ typedef struct { } NMDnsIPConfigData; typedef struct _NMDnsConfigData { + int ifindex; struct _NMDnsManager *self; CList data_lst_head; - int ifindex; } NMDnsConfigData; #define NM_TYPE_DNS_MANAGER (nm_dns_manager_get_type ())