mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-27 07:56:14 +01:00
ghash: fix bug introduced by valgrind fix
g_hash_table_new_full() had an invocation of g_hash_table_realloc_key_or_value_array() with the @is_big argument incorrectly hardcoded to FALSE, even though later in the function the values of have_big_keys and have_big_values would be set conditionally. This never caused problems before because on 64bit platforms, this would result in the allocation of a guint-sized array (which would be fine, as have_big_keys and have_big_values would always start out as false) and on 32bit platforms, this function ignored the value and always allocated a gpointer-sized array. Since merge request GNOME/glib!845 we have the possibility for have_big_keys and have_big_values to start out as TRUE on 64bit platforms. We need to make sure we pass the argument through correctly.
This commit is contained in:
parent
a8c265c6b1
commit
96ce92025d
35
glib/ghash.c
35
glib/ghash.c
@ -1019,22 +1019,6 @@ g_hash_table_new_full (GHashFunc hash_func,
|
||||
GHashTable *hash_table;
|
||||
gboolean small;
|
||||
|
||||
hash_table = g_slice_new (GHashTable);
|
||||
g_hash_table_set_shift (hash_table, HASH_TABLE_MIN_SHIFT);
|
||||
g_atomic_ref_count_init (&hash_table->ref_count);
|
||||
hash_table->nnodes = 0;
|
||||
hash_table->noccupied = 0;
|
||||
hash_table->hash_func = hash_func ? hash_func : g_direct_hash;
|
||||
hash_table->key_equal_func = key_equal_func;
|
||||
#ifndef G_DISABLE_ASSERT
|
||||
hash_table->version = 0;
|
||||
#endif
|
||||
hash_table->key_destroy_func = key_destroy_func;
|
||||
hash_table->value_destroy_func = value_destroy_func;
|
||||
hash_table->keys = g_hash_table_realloc_key_or_value_array (NULL, hash_table->size, FALSE);
|
||||
hash_table->values = hash_table->keys;
|
||||
hash_table->hashes = g_new0 (guint, hash_table->size);
|
||||
|
||||
/* We want to use small arrays only if:
|
||||
* - we are running on a system where that makes sense (64 bit); and
|
||||
* - we are not running under valgrind.
|
||||
@ -1050,8 +1034,23 @@ g_hash_table_new_full (GHashFunc hash_func,
|
||||
# endif
|
||||
#endif
|
||||
|
||||
hash_table->have_big_keys = !small;
|
||||
hash_table->have_big_values = !small;
|
||||
hash_table = g_slice_new (GHashTable);
|
||||
g_hash_table_set_shift (hash_table, HASH_TABLE_MIN_SHIFT);
|
||||
g_atomic_ref_count_init (&hash_table->ref_count);
|
||||
hash_table->nnodes = 0;
|
||||
hash_table->noccupied = 0;
|
||||
hash_table->hash_func = hash_func ? hash_func : g_direct_hash;
|
||||
hash_table->key_equal_func = key_equal_func;
|
||||
#ifndef G_DISABLE_ASSERT
|
||||
hash_table->version = 0;
|
||||
#endif
|
||||
hash_table->key_destroy_func = key_destroy_func;
|
||||
hash_table->value_destroy_func = value_destroy_func;
|
||||
hash_table->have_big_keys = !small;
|
||||
hash_table->have_big_values = !small;
|
||||
hash_table->keys = g_hash_table_realloc_key_or_value_array (NULL, hash_table->size, hash_table->have_big_keys);
|
||||
hash_table->values = hash_table->keys;
|
||||
hash_table->hashes = g_new0 (guint, hash_table->size);
|
||||
|
||||
return hash_table;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user