all: use nm_direct_hash() instead of g_direct_hash()
We also do this for libnm, where it causes visible changes in behavior. But if somebody would rely on the hashing implementation for hash tables, it would be seriously flawed.
This commit is contained in:
@@ -3308,7 +3308,7 @@ _dynamic_options_set (const NMMetaAbstractInfo *abstract_info,
|
|||||||
PropertyInfFlags v, v2;
|
PropertyInfFlags v, v2;
|
||||||
|
|
||||||
if (G_UNLIKELY (!cache))
|
if (G_UNLIKELY (!cache))
|
||||||
cache = g_hash_table_new (NULL, NULL);
|
cache = g_hash_table_new (nm_direct_hash, NULL);
|
||||||
|
|
||||||
if (g_hash_table_lookup_extended (cache, (gpointer) abstract_info, NULL, &p))
|
if (g_hash_table_lookup_extended (cache, (gpointer) abstract_info, NULL, &p))
|
||||||
v = GPOINTER_TO_UINT (p);
|
v = GPOINTER_TO_UINT (p);
|
||||||
|
@@ -102,7 +102,7 @@ test_client_meta_check (void)
|
|||||||
|
|
||||||
if (info->valid_parts) {
|
if (info->valid_parts) {
|
||||||
gsize i, l;
|
gsize i, l;
|
||||||
gs_unref_hashtable GHashTable *dup = g_hash_table_new (NULL, NULL);
|
gs_unref_hashtable GHashTable *dup = g_hash_table_new (nm_direct_hash, NULL);
|
||||||
|
|
||||||
l = NM_PTRARRAY_LEN (info->valid_parts);
|
l = NM_PTRARRAY_LEN (info->valid_parts);
|
||||||
g_assert (l >= 2);
|
g_assert (l >= 2);
|
||||||
|
@@ -192,7 +192,7 @@ nm_manager_init (NMManager *manager)
|
|||||||
priv->state = NM_STATE_UNKNOWN;
|
priv->state = NM_STATE_UNKNOWN;
|
||||||
priv->connectivity = NM_CONNECTIVITY_UNKNOWN;
|
priv->connectivity = NM_CONNECTIVITY_UNKNOWN;
|
||||||
|
|
||||||
priv->permissions = g_hash_table_new (NULL, NULL);
|
priv->permissions = g_hash_table_new (nm_direct_hash, NULL);
|
||||||
priv->devices = g_ptr_array_new ();
|
priv->devices = g_ptr_array_new ();
|
||||||
priv->all_devices = g_ptr_array_new ();
|
priv->all_devices = g_ptr_array_new ();
|
||||||
priv->active_connections = g_ptr_array_new ();
|
priv->active_connections = g_ptr_array_new ();
|
||||||
|
@@ -428,7 +428,7 @@ nm_arping_manager_init (NMArpingManager *self)
|
|||||||
{
|
{
|
||||||
NMArpingManagerPrivate *priv = NM_ARPING_MANAGER_GET_PRIVATE (self);
|
NMArpingManagerPrivate *priv = NM_ARPING_MANAGER_GET_PRIVATE (self);
|
||||||
|
|
||||||
priv->addresses = g_hash_table_new_full (NULL, NULL,
|
priv->addresses = g_hash_table_new_full (nm_direct_hash, NULL,
|
||||||
NULL, destroy_address_info);
|
NULL, destroy_address_info);
|
||||||
priv->state = STATE_INIT;
|
priv->state = STATE_INIT;
|
||||||
}
|
}
|
||||||
|
@@ -351,7 +351,7 @@ nm_device_factory_manager_load_factories (NMDeviceFactoryManagerFactoryFunc call
|
|||||||
g_return_if_fail (factories_by_link == NULL);
|
g_return_if_fail (factories_by_link == NULL);
|
||||||
g_return_if_fail (factories_by_setting == NULL);
|
g_return_if_fail (factories_by_setting == NULL);
|
||||||
|
|
||||||
factories_by_link = g_hash_table_new_full (NULL, NULL, NULL, g_object_unref);
|
factories_by_link = g_hash_table_new_full (nm_direct_hash, NULL, NULL, g_object_unref);
|
||||||
factories_by_setting = g_hash_table_new_full (nm_str_hash, g_str_equal, NULL, (GDestroyNotify) factories_list_unref);
|
factories_by_setting = g_hash_table_new_full (nm_str_hash, g_str_equal, NULL, (GDestroyNotify) factories_list_unref);
|
||||||
|
|
||||||
#define _ADD_INTERNAL(get_type_fcn) \
|
#define _ADD_INTERNAL(get_type_fcn) \
|
||||||
|
@@ -6217,7 +6217,7 @@ shared4_new_config (NMDevice *self, NMConnection *connection)
|
|||||||
guint32 count = 0;
|
guint32 count = 0;
|
||||||
|
|
||||||
if (G_UNLIKELY (!shared_ips))
|
if (G_UNLIKELY (!shared_ips))
|
||||||
shared_ips = g_hash_table_new (NULL, NULL);
|
shared_ips = g_hash_table_new (nm_direct_hash, NULL);
|
||||||
else {
|
else {
|
||||||
while (g_hash_table_lookup (shared_ips, GUINT_TO_POINTER (start + count))) {
|
while (g_hash_table_lookup (shared_ips, GUINT_TO_POINTER (start + count))) {
|
||||||
count += ntohl (0x100);
|
count += ntohl (0x100);
|
||||||
@@ -12072,7 +12072,7 @@ nm_device_recheck_available_connections (NMDevice *self)
|
|||||||
priv = NM_DEVICE_GET_PRIVATE(self);
|
priv = NM_DEVICE_GET_PRIVATE(self);
|
||||||
|
|
||||||
if (g_hash_table_size (priv->available_connections) > 0) {
|
if (g_hash_table_size (priv->available_connections) > 0) {
|
||||||
prune_list = g_hash_table_new (NULL, NULL);
|
prune_list = g_hash_table_new (nm_direct_hash, NULL);
|
||||||
g_hash_table_iter_init (&h_iter, priv->available_connections);
|
g_hash_table_iter_init (&h_iter, priv->available_connections);
|
||||||
while (g_hash_table_iter_next (&h_iter, (gpointer *) &connection, NULL))
|
while (g_hash_table_iter_next (&h_iter, (gpointer *) &connection, NULL))
|
||||||
g_hash_table_add (prune_list, connection);
|
g_hash_table_add (prune_list, connection);
|
||||||
@@ -14131,7 +14131,7 @@ nm_device_init (NMDevice *self)
|
|||||||
priv->rfkill_type = RFKILL_TYPE_UNKNOWN;
|
priv->rfkill_type = RFKILL_TYPE_UNKNOWN;
|
||||||
priv->unmanaged_flags = NM_UNMANAGED_PLATFORM_INIT;
|
priv->unmanaged_flags = NM_UNMANAGED_PLATFORM_INIT;
|
||||||
priv->unmanaged_mask = priv->unmanaged_flags;
|
priv->unmanaged_mask = priv->unmanaged_flags;
|
||||||
priv->available_connections = g_hash_table_new_full (NULL, NULL, g_object_unref, NULL);
|
priv->available_connections = g_hash_table_new_full (nm_direct_hash, NULL, g_object_unref, NULL);
|
||||||
priv->ip6_saved_properties = g_hash_table_new_full (nm_str_hash, g_str_equal, NULL, g_free);
|
priv->ip6_saved_properties = g_hash_table_new_full (nm_str_hash, g_str_equal, NULL, g_free);
|
||||||
priv->sys_iface_state = NM_DEVICE_SYS_IFACE_STATE_EXTERNAL;
|
priv->sys_iface_state = NM_DEVICE_SYS_IFACE_STATE_EXTERNAL;
|
||||||
|
|
||||||
|
@@ -300,7 +300,7 @@ nm_dhcp_listener_init (NMDhcpListener *self)
|
|||||||
NMDhcpListenerPrivate *priv = NM_DHCP_LISTENER_GET_PRIVATE (self);
|
NMDhcpListenerPrivate *priv = NM_DHCP_LISTENER_GET_PRIVATE (self);
|
||||||
|
|
||||||
/* Maps GDBusConnection :: signal-id */
|
/* Maps GDBusConnection :: signal-id */
|
||||||
priv->connections = g_hash_table_new (NULL, NULL);
|
priv->connections = g_hash_table_new (nm_direct_hash, NULL);
|
||||||
|
|
||||||
priv->dbus_mgr = nm_bus_manager_get ();
|
priv->dbus_mgr = nm_bus_manager_get ();
|
||||||
|
|
||||||
|
@@ -429,7 +429,7 @@ nm_dhcp_manager_init (NMDhcpManager *self)
|
|||||||
nm_log_info (LOGD_DHCP, "dhcp-init: Using DHCP client '%s'", client_factory->name);
|
nm_log_info (LOGD_DHCP, "dhcp-init: Using DHCP client '%s'", client_factory->name);
|
||||||
|
|
||||||
priv->client_factory = client_factory;
|
priv->client_factory = client_factory;
|
||||||
priv->clients = g_hash_table_new_full (NULL, NULL,
|
priv->clients = g_hash_table_new_full (nm_direct_hash, NULL,
|
||||||
NULL,
|
NULL,
|
||||||
(GDestroyNotify) g_object_unref);
|
(GDestroyNotify) g_object_unref);
|
||||||
}
|
}
|
||||||
|
@@ -307,7 +307,7 @@ private_server_new (const char *path,
|
|||||||
g_signal_connect (server, "new-connection",
|
g_signal_connect (server, "new-connection",
|
||||||
G_CALLBACK (private_server_new_connection), s);
|
G_CALLBACK (private_server_new_connection), s);
|
||||||
|
|
||||||
s->obj_managers = g_hash_table_new_full (NULL, NULL,
|
s->obj_managers = g_hash_table_new_full (nm_direct_hash, NULL,
|
||||||
(GDestroyNotify) private_server_manager_destroy,
|
(GDestroyNotify) private_server_manager_destroy,
|
||||||
g_free);
|
g_free);
|
||||||
s->manager = manager;
|
s->manager = manager;
|
||||||
|
@@ -466,7 +466,7 @@ nm_checkpoint_init (NMCheckpoint *self)
|
|||||||
{
|
{
|
||||||
NMCheckpointPrivate *priv = NM_CHECKPOINT_GET_PRIVATE (self);
|
NMCheckpointPrivate *priv = NM_CHECKPOINT_GET_PRIVATE (self);
|
||||||
|
|
||||||
priv->devices = g_hash_table_new_full (NULL, NULL,
|
priv->devices = g_hash_table_new_full (nm_direct_hash, NULL,
|
||||||
NULL, device_checkpoint_destroy);
|
NULL, device_checkpoint_destroy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -345,7 +345,7 @@ static void
|
|||||||
_ensure_requests (void)
|
_ensure_requests (void)
|
||||||
{
|
{
|
||||||
if (G_UNLIKELY (requests == NULL)) {
|
if (G_UNLIKELY (requests == NULL)) {
|
||||||
requests = g_hash_table_new_full (NULL,
|
requests = g_hash_table_new_full (nm_direct_hash,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
(GDestroyNotify) dispatcher_info_free);
|
(GDestroyNotify) dispatcher_info_free);
|
||||||
|
@@ -501,7 +501,7 @@ nm_exported_object_create_skeletons (NMExportedObject *self,
|
|||||||
|
|
||||||
ifdata->property_changed_signal_id = g_signal_lookup ("properties-changed", G_OBJECT_TYPE (ifdata->interface));
|
ifdata->property_changed_signal_id = g_signal_lookup ("properties-changed", G_OBJECT_TYPE (ifdata->interface));
|
||||||
|
|
||||||
ifdata->pending_notifies = g_hash_table_new_full (NULL,
|
ifdata->pending_notifies = g_hash_table_new_full (nm_direct_hash,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
(GDestroyNotify) g_variant_unref);
|
(GDestroyNotify) g_variant_unref);
|
||||||
|
@@ -3016,7 +3016,7 @@ find_slaves (NMManager *manager,
|
|||||||
s_con = nm_connection_get_setting_connection (NM_CONNECTION (connection));
|
s_con = nm_connection_get_setting_connection (NM_CONNECTION (connection));
|
||||||
g_return_val_if_fail (s_con, NULL);
|
g_return_val_if_fail (s_con, NULL);
|
||||||
|
|
||||||
devices = g_hash_table_new (NULL, NULL);
|
devices = g_hash_table_new (nm_direct_hash, NULL);
|
||||||
|
|
||||||
/* Search through all connections, not only inactive ones, because
|
/* Search through all connections, not only inactive ones, because
|
||||||
* even if a slave was already active, it might be deactivated during
|
* even if a slave was already active, it might be deactivated during
|
||||||
@@ -5105,7 +5105,7 @@ nm_manager_write_device_state (NMManager *self)
|
|||||||
gs_unref_hashtable GHashTable *seen_ifindexes = NULL;
|
gs_unref_hashtable GHashTable *seen_ifindexes = NULL;
|
||||||
gint nm_owned;
|
gint nm_owned;
|
||||||
|
|
||||||
seen_ifindexes = g_hash_table_new (NULL, NULL);
|
seen_ifindexes = g_hash_table_new (nm_direct_hash, NULL);
|
||||||
|
|
||||||
for (devices = priv->devices; devices; devices = devices->next) {
|
for (devices = priv->devices; devices; devices = devices->next) {
|
||||||
NMDevice *device = NM_DEVICE (devices->data);
|
NMDevice *device = NM_DEVICE (devices->data);
|
||||||
@@ -6233,7 +6233,7 @@ nm_manager_init (NMManager *self)
|
|||||||
priv->timestamp_update_id = g_timeout_add_seconds (300, (GSourceFunc) periodic_update_active_connection_timestamps, self);
|
priv->timestamp_update_id = g_timeout_add_seconds (300, (GSourceFunc) periodic_update_active_connection_timestamps, self);
|
||||||
|
|
||||||
priv->metered = NM_METERED_UNKNOWN;
|
priv->metered = NM_METERED_UNKNOWN;
|
||||||
priv->sleep_devices = g_hash_table_new (NULL, NULL);
|
priv->sleep_devices = g_hash_table_new (nm_direct_hash, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@@ -333,7 +333,7 @@ device_ip6_prefix_delegated (NMDevice *device,
|
|||||||
/* Allocate a delegation delegation for new prefix. */
|
/* Allocate a delegation delegation for new prefix. */
|
||||||
g_array_set_size (priv->ip6_prefix_delegations, i + 1);
|
g_array_set_size (priv->ip6_prefix_delegations, i + 1);
|
||||||
delegation = &g_array_index (priv->ip6_prefix_delegations, IP6PrefixDelegation, i);
|
delegation = &g_array_index (priv->ip6_prefix_delegations, IP6PrefixDelegation, i);
|
||||||
delegation->subnets = g_hash_table_new (NULL, NULL);
|
delegation->subnets = g_hash_table_new (nm_direct_hash, NULL);
|
||||||
delegation->next_subnet = 0;
|
delegation->next_subnet = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2484,8 +2484,8 @@ nm_policy_init (NMPolicy *self)
|
|||||||
else /* default - full mode */
|
else /* default - full mode */
|
||||||
priv->hostname_mode = NM_POLICY_HOSTNAME_MODE_FULL;
|
priv->hostname_mode = NM_POLICY_HOSTNAME_MODE_FULL;
|
||||||
|
|
||||||
priv->devices = g_hash_table_new (NULL, NULL);
|
priv->devices = g_hash_table_new (nm_direct_hash, NULL);
|
||||||
priv->pending_active_connections = g_hash_table_new (NULL, NULL);
|
priv->pending_active_connections = g_hash_table_new (nm_direct_hash, NULL);
|
||||||
priv->ip6_prefix_delegations = g_array_new (FALSE, FALSE, sizeof (IP6PrefixDelegation));
|
priv->ip6_prefix_delegations = g_array_new (FALSE, FALSE, sizeof (IP6PrefixDelegation));
|
||||||
g_array_set_clear_func (priv->ip6_prefix_delegations, clear_ip6_prefix_delegation);
|
g_array_set_clear_func (priv->ip6_prefix_delegations, clear_ip6_prefix_delegation);
|
||||||
}
|
}
|
||||||
|
@@ -258,7 +258,7 @@ ck_init (NMSessionMonitor *monitor)
|
|||||||
|
|
||||||
if (g_file_query_exists (file, NULL)) {
|
if (g_file_query_exists (file, NULL)) {
|
||||||
if ((monitor->ck.monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL, &error))) {
|
if ((monitor->ck.monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL, &error))) {
|
||||||
monitor->ck.cache = g_hash_table_new_full (NULL, NULL, NULL, g_free);
|
monitor->ck.cache = g_hash_table_new_full (nm_direct_hash, NULL, NULL, g_free);
|
||||||
g_signal_connect (monitor->ck.monitor,
|
g_signal_connect (monitor->ck.monitor,
|
||||||
"changed",
|
"changed",
|
||||||
G_CALLBACK (ck_changed),
|
G_CALLBACK (ck_changed),
|
||||||
|
@@ -6696,7 +6696,7 @@ nm_linux_platform_init (NMLinuxPlatform *self)
|
|||||||
priv->delayed_action.list_master_connected = g_ptr_array_new ();
|
priv->delayed_action.list_master_connected = g_ptr_array_new ();
|
||||||
priv->delayed_action.list_refresh_link = g_ptr_array_new ();
|
priv->delayed_action.list_refresh_link = g_ptr_array_new ();
|
||||||
priv->delayed_action.list_wait_for_nl_response = g_array_new (FALSE, TRUE, sizeof (DelayedActionWaitForNlResponseData));
|
priv->delayed_action.list_wait_for_nl_response = g_array_new (FALSE, TRUE, sizeof (DelayedActionWaitForNlResponseData));
|
||||||
priv->wifi_data = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify) wifi_utils_deinit);
|
priv->wifi_data = g_hash_table_new_full (nm_direct_hash, NULL, NULL, (GDestroyNotify) wifi_utils_deinit);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@@ -594,7 +594,7 @@ nm_platform_link_get_all (NMPlatform *self, gboolean sort_by_name)
|
|||||||
* further by moving children/slaves to the end. */
|
* further by moving children/slaves to the end. */
|
||||||
g_ptr_array_sort_with_data (links, _link_get_all_presort, GINT_TO_POINTER (sort_by_name));
|
g_ptr_array_sort_with_data (links, _link_get_all_presort, GINT_TO_POINTER (sort_by_name));
|
||||||
|
|
||||||
unseen = g_hash_table_new (NULL, NULL);
|
unseen = g_hash_table_new (nm_direct_hash, NULL);
|
||||||
for (i = 0; i < links->len; i++) {
|
for (i = 0; i < links->len; i++) {
|
||||||
item = NMP_OBJECT_CAST_LINK (links->pdata[i]);
|
item = NMP_OBJECT_CAST_LINK (links->pdata[i]);
|
||||||
nm_assert (item->ifindex > 0);
|
nm_assert (item->ifindex > 0);
|
||||||
@@ -3175,7 +3175,7 @@ ip4_addr_subnets_build_index (const GPtrArray *addresses,
|
|||||||
|
|
||||||
nm_assert (addresses && addresses->len);
|
nm_assert (addresses && addresses->len);
|
||||||
|
|
||||||
subnets = g_hash_table_new (NULL, NULL);
|
subnets = g_hash_table_new (nm_direct_hash, NULL);
|
||||||
|
|
||||||
/* Build a hash table of all addresses per subnet */
|
/* Build a hash table of all addresses per subnet */
|
||||||
for (i = 0; i < addresses->len; i++) {
|
for (i = 0; i < addresses->len; i++) {
|
||||||
|
@@ -172,7 +172,7 @@ nm_inotify_helper_init (NMInotifyHelper *self)
|
|||||||
{
|
{
|
||||||
NMInotifyHelperPrivate *priv = NM_INOTIFY_HELPER_GET_PRIVATE (self);
|
NMInotifyHelperPrivate *priv = NM_INOTIFY_HELPER_GET_PRIVATE (self);
|
||||||
|
|
||||||
priv->wd_refs = g_hash_table_new (NULL, NULL);
|
priv->wd_refs = g_hash_table_new (nm_direct_hash, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@@ -515,7 +515,7 @@ read_connections (SettingsPluginIfcfg *plugin)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
alive_connections = g_hash_table_new (NULL, NULL);
|
alive_connections = g_hash_table_new (nm_direct_hash, NULL);
|
||||||
|
|
||||||
filenames = g_ptr_array_new_with_free_func (g_free);
|
filenames = g_ptr_array_new_with_free_func (g_free);
|
||||||
while ((item = g_dir_read_name (dir))) {
|
while ((item = g_dir_read_name (dir))) {
|
||||||
|
@@ -435,7 +435,7 @@ read_connections (NMSettingsPlugin *config)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
alive_connections = g_hash_table_new (NULL, NULL);
|
alive_connections = g_hash_table_new (nm_direct_hash, NULL);
|
||||||
|
|
||||||
filenames = g_ptr_array_new_with_free_func (g_free);
|
filenames = g_ptr_array_new_with_free_func (g_free);
|
||||||
while ((item = g_dir_read_name (dir))) {
|
while ((item = g_dir_read_name (dir))) {
|
||||||
|
@@ -432,7 +432,7 @@ test_nm_utils_array_remove_at_indexes (void)
|
|||||||
|
|
||||||
idx = g_array_new (FALSE, FALSE, sizeof (guint));
|
idx = g_array_new (FALSE, FALSE, sizeof (guint));
|
||||||
array = g_array_new (FALSE, FALSE, sizeof (gssize));
|
array = g_array_new (FALSE, FALSE, sizeof (gssize));
|
||||||
unique = g_hash_table_new (NULL, NULL);
|
unique = g_hash_table_new (nm_direct_hash, NULL);
|
||||||
for (i_len = 1; i_len < 20; i_len++) {
|
for (i_len = 1; i_len < 20; i_len++) {
|
||||||
for (i_idx_len = 1; i_idx_len <= i_len; i_idx_len++) {
|
for (i_idx_len = 1; i_idx_len <= i_len; i_idx_len++) {
|
||||||
for (i_rnd = 0; i_rnd < 20; i_rnd++) {
|
for (i_rnd = 0; i_rnd < 20; i_rnd++) {
|
||||||
|
Reference in New Issue
Block a user