all: use nm_str_hash() instead of g_str_hash()
We also do this for libnm and libnm-core, 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:
@@ -587,7 +587,7 @@ nm_connection_diff (NMConnection *a,
|
|||||||
if (a == b)
|
if (a == b)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
diffs = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_hash_table_destroy);
|
diffs = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, (GDestroyNotify) g_hash_table_destroy);
|
||||||
|
|
||||||
/* Diff A to B, then B to A to capture keys in B that aren't in A */
|
/* Diff A to B, then B to A to capture keys in B that aren't in A */
|
||||||
if (diff_one_connection (a, b, flags, FALSE, diffs))
|
if (diff_one_connection (a, b, flags, FALSE, diffs))
|
||||||
@@ -1370,7 +1370,7 @@ nm_connection_verify_secrets (NMConnection *connection, GError **error)
|
|||||||
* @parameters: (allow-none) (element-type utf8 gpointer): a #GHashTable with
|
* @parameters: (allow-none) (element-type utf8 gpointer): a #GHashTable with
|
||||||
* normalization parameters to allow customization of the normalization by providing
|
* normalization parameters to allow customization of the normalization by providing
|
||||||
* specific arguments. Unknown arguments will be ignored and the default will be
|
* specific arguments. Unknown arguments will be ignored and the default will be
|
||||||
* used. The keys must be strings, hashed by g_str_hash() and g_str_equal() functions.
|
* used. The keys must be strings compared with g_str_equal() function.
|
||||||
* The values are opaque and depend on the parameter name.
|
* The values are opaque and depend on the parameter name.
|
||||||
* @modified: (out) (allow-none): outputs whether any settings were modified.
|
* @modified: (out) (allow-none): outputs whether any settings were modified.
|
||||||
* @error: location to store error, or %NULL. Contains the reason,
|
* @error: location to store error, or %NULL. Contains the reason,
|
||||||
@@ -2716,7 +2716,7 @@ nm_connection_get_private (NMConnection *connection)
|
|||||||
priv, (GDestroyNotify) nm_connection_private_free);
|
priv, (GDestroyNotify) nm_connection_private_free);
|
||||||
|
|
||||||
priv->self = connection;
|
priv->self = connection;
|
||||||
priv->settings = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_object_unref);
|
priv->settings = g_hash_table_new_full (nm_str_hash, g_str_equal, NULL, g_object_unref);
|
||||||
}
|
}
|
||||||
|
|
||||||
return priv;
|
return priv;
|
||||||
|
@@ -763,7 +763,7 @@ read_hash_of_string (GKeyFile *file, NMSetting *setting, const char *key)
|
|||||||
if (NM_IS_SETTING_USER (setting)) {
|
if (NM_IS_SETTING_USER (setting)) {
|
||||||
gs_unref_hashtable GHashTable *data = NULL;
|
gs_unref_hashtable GHashTable *data = NULL;
|
||||||
|
|
||||||
data = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
data = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, g_free);
|
||||||
for (iter = (const char *const*) keys; *iter; iter++) {
|
for (iter = (const char *const*) keys; *iter; iter++) {
|
||||||
gs_free char *to_free = NULL;
|
gs_free char *to_free = NULL;
|
||||||
char *value = NULL;
|
char *value = NULL;
|
||||||
|
@@ -892,7 +892,7 @@ nm_setting_bond_init (NMSettingBond *setting)
|
|||||||
{
|
{
|
||||||
NMSettingBondPrivate *priv = NM_SETTING_BOND_GET_PRIVATE (setting);
|
NMSettingBondPrivate *priv = NM_SETTING_BOND_GET_PRIVATE (setting);
|
||||||
|
|
||||||
priv->options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
priv->options = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, g_free);
|
||||||
|
|
||||||
/* Default values: */
|
/* Default values: */
|
||||||
nm_setting_bond_add_option (setting, NM_SETTING_BOND_OPTION_MODE, "balance-rr");
|
nm_setting_bond_add_option (setting, NM_SETTING_BOND_OPTION_MODE, "balance-rr");
|
||||||
|
@@ -593,7 +593,7 @@ nm_ip_address_set_attribute (NMIPAddress *address, const char *name, GVariant *v
|
|||||||
g_return_if_fail (strcmp (name, "address") != 0 && strcmp (name, "prefix") != 0);
|
g_return_if_fail (strcmp (name, "address") != 0 && strcmp (name, "prefix") != 0);
|
||||||
|
|
||||||
if (!address->attributes) {
|
if (!address->attributes) {
|
||||||
address->attributes = g_hash_table_new_full (g_str_hash, g_str_equal,
|
address->attributes = g_hash_table_new_full (nm_str_hash, g_str_equal,
|
||||||
g_free, (GDestroyNotify) g_variant_unref);
|
g_free, (GDestroyNotify) g_variant_unref);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1227,7 +1227,7 @@ nm_ip_route_set_attribute (NMIPRoute *route, const char *name, GVariant *value)
|
|||||||
&& strcmp (name, "next-hop") != 0 && strcmp (name, "metric") != 0);
|
&& strcmp (name, "next-hop") != 0 && strcmp (name, "metric") != 0);
|
||||||
|
|
||||||
if (!route->attributes) {
|
if (!route->attributes) {
|
||||||
route->attributes = g_hash_table_new_full (g_str_hash, g_str_equal,
|
route->attributes = g_hash_table_new_full (nm_str_hash, g_str_equal,
|
||||||
g_free, (GDestroyNotify) g_variant_unref);
|
g_free, (GDestroyNotify) g_variant_unref);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -210,7 +210,7 @@ nm_setting_user_check_val (const char *val, GError **error)
|
|||||||
static GHashTable *
|
static GHashTable *
|
||||||
_create_data_hash (void)
|
_create_data_hash (void)
|
||||||
{
|
{
|
||||||
return g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
return g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, g_free);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -722,8 +722,8 @@ nm_setting_vpn_init (NMSettingVpn *setting)
|
|||||||
{
|
{
|
||||||
NMSettingVpnPrivate *priv = NM_SETTING_VPN_GET_PRIVATE (setting);
|
NMSettingVpnPrivate *priv = NM_SETTING_VPN_GET_PRIVATE (setting);
|
||||||
|
|
||||||
priv->data = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
priv->data = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, g_free);
|
||||||
priv->secrets = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, destroy_one_secret);
|
priv->secrets = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, destroy_one_secret);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@@ -829,7 +829,7 @@ nm_setting_wired_init (NMSettingWired *setting)
|
|||||||
{
|
{
|
||||||
NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE (setting);
|
NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE (setting);
|
||||||
|
|
||||||
priv->s390_options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
priv->s390_options = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, g_free);
|
||||||
|
|
||||||
/* We use GArray rather than GPtrArray so it will automatically be NULL-terminated */
|
/* We use GArray rather than GPtrArray so it will automatically be NULL-terminated */
|
||||||
priv->mac_address_blacklist = g_array_new (TRUE, FALSE, sizeof (char *));
|
priv->mac_address_blacklist = g_array_new (TRUE, FALSE, sizeof (char *));
|
||||||
|
@@ -95,7 +95,7 @@ _ensure_registered (void)
|
|||||||
{
|
{
|
||||||
if (G_UNLIKELY (registered_settings == NULL)) {
|
if (G_UNLIKELY (registered_settings == NULL)) {
|
||||||
nm_g_type_init ();
|
nm_g_type_init ();
|
||||||
registered_settings = g_hash_table_new (g_str_hash, g_str_equal);
|
registered_settings = g_hash_table_new (nm_str_hash, g_str_equal);
|
||||||
registered_settings_by_type = g_hash_table_new (_nm_gtype_hash, _nm_gtype_equal);
|
registered_settings_by_type = g_hash_table_new (_nm_gtype_hash, _nm_gtype_equal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -807,7 +807,7 @@ _nm_setting_new_from_dbus (GType setting_type,
|
|||||||
GVariant *entry, *entry_key;
|
GVariant *entry, *entry_key;
|
||||||
char *key;
|
char *key;
|
||||||
|
|
||||||
keys = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
|
keys = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, NULL);
|
||||||
|
|
||||||
g_variant_iter_init (&iter, setting_dict);
|
g_variant_iter_init (&iter, setting_dict);
|
||||||
while ((entry = g_variant_iter_next_value (&iter))) {
|
while ((entry = g_variant_iter_next_value (&iter))) {
|
||||||
@@ -1359,7 +1359,7 @@ nm_setting_diff (NMSetting *a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (*results == NULL) {
|
if (*results == NULL) {
|
||||||
*results = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
|
*results = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, NULL);
|
||||||
results_created = TRUE;
|
results_created = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -144,7 +144,7 @@ init_lang_to_encodings_hash (void)
|
|||||||
if (G_UNLIKELY (langToEncodings5 == NULL)) {
|
if (G_UNLIKELY (langToEncodings5 == NULL)) {
|
||||||
/* Five-letter codes */
|
/* Five-letter codes */
|
||||||
enc = (struct IsoLangToEncodings *) &isoLangEntries5[0];
|
enc = (struct IsoLangToEncodings *) &isoLangEntries5[0];
|
||||||
langToEncodings5 = g_hash_table_new (g_str_hash, g_str_equal);
|
langToEncodings5 = g_hash_table_new (nm_str_hash, g_str_equal);
|
||||||
while (enc->lang) {
|
while (enc->lang) {
|
||||||
g_hash_table_insert (langToEncodings5, (gpointer) enc->lang,
|
g_hash_table_insert (langToEncodings5, (gpointer) enc->lang,
|
||||||
(gpointer) enc->encodings);
|
(gpointer) enc->encodings);
|
||||||
@@ -155,7 +155,7 @@ init_lang_to_encodings_hash (void)
|
|||||||
if (G_UNLIKELY (langToEncodings2 == NULL)) {
|
if (G_UNLIKELY (langToEncodings2 == NULL)) {
|
||||||
/* Two-letter codes */
|
/* Two-letter codes */
|
||||||
enc = (struct IsoLangToEncodings *) &isoLangEntries2[0];
|
enc = (struct IsoLangToEncodings *) &isoLangEntries2[0];
|
||||||
langToEncodings2 = g_hash_table_new (g_str_hash, g_str_equal);
|
langToEncodings2 = g_hash_table_new (nm_str_hash, g_str_equal);
|
||||||
while (enc->lang) {
|
while (enc->lang) {
|
||||||
g_hash_table_insert (langToEncodings2, (gpointer) enc->lang,
|
g_hash_table_insert (langToEncodings2, (gpointer) enc->lang,
|
||||||
(gpointer) enc->encodings);
|
(gpointer) enc->encodings);
|
||||||
@@ -512,7 +512,7 @@ _nm_utils_strdict_from_dbus (GVariant *dbus_value,
|
|||||||
const char *key, *value;
|
const char *key, *value;
|
||||||
GHashTable *hash;
|
GHashTable *hash;
|
||||||
|
|
||||||
hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
hash = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, g_free);
|
||||||
g_variant_iter_init (&iter, dbus_value);
|
g_variant_iter_init (&iter, dbus_value);
|
||||||
while (g_variant_iter_next (&iter, "{&s&s}", &key, &value))
|
while (g_variant_iter_next (&iter, "{&s&s}", &key, &value))
|
||||||
g_hash_table_insert (hash, g_strdup (key), g_strdup (value));
|
g_hash_table_insert (hash, g_strdup (key), g_strdup (value));
|
||||||
@@ -527,7 +527,7 @@ _nm_utils_copy_strdict (GHashTable *strdict)
|
|||||||
GHashTableIter iter;
|
GHashTableIter iter;
|
||||||
gpointer key, value;
|
gpointer key, value;
|
||||||
|
|
||||||
copy = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
copy = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, g_free);
|
||||||
if (strdict) {
|
if (strdict) {
|
||||||
g_hash_table_iter_init (&iter, strdict);
|
g_hash_table_iter_init (&iter, strdict);
|
||||||
while (g_hash_table_iter_next (&iter, &key, &value))
|
while (g_hash_table_iter_next (&iter, &key, &value))
|
||||||
@@ -4861,7 +4861,7 @@ nm_utils_parse_variant_attributes (const char *string,
|
|||||||
g_return_val_if_fail (key_value_separator, NULL);
|
g_return_val_if_fail (key_value_separator, NULL);
|
||||||
g_return_val_if_fail (!error || !*error, NULL);
|
g_return_val_if_fail (!error || !*error, NULL);
|
||||||
|
|
||||||
ht = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_variant_unref);
|
ht = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, (GDestroyNotify) g_variant_unref);
|
||||||
|
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
gs_free char *name = NULL, *value = NULL;
|
gs_free char *name = NULL, *value = NULL;
|
||||||
|
@@ -6098,7 +6098,7 @@ test_g_ptr_array_insert (void)
|
|||||||
static void
|
static void
|
||||||
test_g_hash_table_get_keys_as_array (void)
|
test_g_hash_table_get_keys_as_array (void)
|
||||||
{
|
{
|
||||||
GHashTable *table = g_hash_table_new (g_str_hash, g_str_equal);
|
GHashTable *table = g_hash_table_new (nm_str_hash, g_str_equal);
|
||||||
guint length = 0;
|
guint length = 0;
|
||||||
char **keys;
|
char **keys;
|
||||||
|
|
||||||
@@ -6752,7 +6752,7 @@ test_route_attributes_format (void)
|
|||||||
gs_unref_hashtable GHashTable *ht = NULL;
|
gs_unref_hashtable GHashTable *ht = NULL;
|
||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
ht = g_hash_table_new_full (g_str_hash, g_str_equal,
|
ht = g_hash_table_new_full (nm_str_hash, g_str_equal,
|
||||||
NULL, (GDestroyNotify) g_variant_unref);
|
NULL, (GDestroyNotify) g_variant_unref);
|
||||||
|
|
||||||
str = nm_utils_format_variant_attributes (NULL, ' ', '=');
|
str = nm_utils_format_variant_attributes (NULL, ' ', '=');
|
||||||
|
@@ -2570,7 +2570,7 @@ nm_lldp_neighbor_new (void)
|
|||||||
|
|
||||||
neigh = g_new0 (NMLldpNeighbor, 1);
|
neigh = g_new0 (NMLldpNeighbor, 1);
|
||||||
neigh->refcount = 1;
|
neigh->refcount = 1;
|
||||||
neigh->attrs = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
|
neigh->attrs = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free,
|
||||||
(GDestroyNotify) g_variant_unref);
|
(GDestroyNotify) g_variant_unref);
|
||||||
|
|
||||||
return neigh;
|
return neigh;
|
||||||
|
@@ -51,7 +51,7 @@ nm_dhcp_config_init (NMDhcpConfig *config)
|
|||||||
{
|
{
|
||||||
NMDhcpConfigPrivate *priv = NM_DHCP_CONFIG_GET_PRIVATE (config);
|
NMDhcpConfigPrivate *priv = NM_DHCP_CONFIG_GET_PRIVATE (config);
|
||||||
|
|
||||||
priv->options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
priv->options = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, g_free);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@@ -1458,7 +1458,7 @@ checkpoint_rollback_cb (GObject *object,
|
|||||||
&variant,
|
&variant,
|
||||||
result,
|
result,
|
||||||
&error)) {
|
&error)) {
|
||||||
hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
|
hash = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, NULL);
|
||||||
g_variant_iter_init (&iter, variant);
|
g_variant_iter_init (&iter, variant);
|
||||||
while (g_variant_iter_next (&iter, "{&su}", &path, &r))
|
while (g_variant_iter_next (&iter, "{&su}", &path, &r))
|
||||||
g_hash_table_insert (hash, g_strdup (path), GUINT_TO_POINTER (r));
|
g_hash_table_insert (hash, g_strdup (path), GUINT_TO_POINTER (r));
|
||||||
|
@@ -955,7 +955,7 @@ _nm_object_register_properties (NMObject *object,
|
|||||||
G_CALLBACK (properties_changed), object);
|
G_CALLBACK (properties_changed), object);
|
||||||
g_ptr_array_add (priv->proxies, proxy);
|
g_ptr_array_add (priv->proxies, proxy);
|
||||||
|
|
||||||
instance = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
instance = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, g_free);
|
||||||
priv->property_tables = g_slist_prepend (priv->property_tables, instance);
|
priv->property_tables = g_slist_prepend (priv->property_tables, instance);
|
||||||
|
|
||||||
for (tmp = (NMPropertiesInfo *) info; tmp->name; tmp++) {
|
for (tmp = (NMPropertiesInfo *) info; tmp->name; tmp++) {
|
||||||
|
@@ -728,8 +728,8 @@ nm_vpn_plugin_old_read_vpn_details (int fd,
|
|||||||
if (out_secrets)
|
if (out_secrets)
|
||||||
g_return_val_if_fail (*out_secrets == NULL, FALSE);
|
g_return_val_if_fail (*out_secrets == NULL, FALSE);
|
||||||
|
|
||||||
data = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
data = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, g_free);
|
||||||
secrets = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, free_secret);
|
secrets = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, free_secret);
|
||||||
|
|
||||||
line = g_string_new (NULL);
|
line = g_string_new (NULL);
|
||||||
|
|
||||||
|
@@ -750,8 +750,8 @@ nm_vpn_service_plugin_read_vpn_details (int fd,
|
|||||||
if (out_secrets)
|
if (out_secrets)
|
||||||
g_return_val_if_fail (*out_secrets == NULL, FALSE);
|
g_return_val_if_fail (*out_secrets == NULL, FALSE);
|
||||||
|
|
||||||
data = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
data = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, g_free);
|
||||||
secrets = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, free_secret);
|
secrets = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, free_secret);
|
||||||
|
|
||||||
line = g_string_new (NULL);
|
line = g_string_new (NULL);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user