mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-26 20:22:11 +01:00
Merge branch 'wip/desrt/ghash-valgrind' into 'master'
ghash: Disable small-arrays under valgrind Closes #1749 See merge request GNOME/glib!840
This commit is contained in:
commit
4e2acb47bd
22
glib/ghash.c
22
glib/ghash.c
@ -38,6 +38,7 @@
|
|||||||
#include "gtestutils.h"
|
#include "gtestutils.h"
|
||||||
#include "gslice.h"
|
#include "gslice.h"
|
||||||
#include "grefcount.h"
|
#include "grefcount.h"
|
||||||
|
#include "gvalgrind.h"
|
||||||
|
|
||||||
/* The following #pragma is here so we can do this...
|
/* The following #pragma is here so we can do this...
|
||||||
*
|
*
|
||||||
@ -1016,6 +1017,7 @@ g_hash_table_new_full (GHashFunc hash_func,
|
|||||||
GDestroyNotify value_destroy_func)
|
GDestroyNotify value_destroy_func)
|
||||||
{
|
{
|
||||||
GHashTable *hash_table;
|
GHashTable *hash_table;
|
||||||
|
gboolean small;
|
||||||
|
|
||||||
hash_table = g_slice_new (GHashTable);
|
hash_table = g_slice_new (GHashTable);
|
||||||
g_hash_table_set_shift (hash_table, HASH_TABLE_MIN_SHIFT);
|
g_hash_table_set_shift (hash_table, HASH_TABLE_MIN_SHIFT);
|
||||||
@ -1033,14 +1035,24 @@ g_hash_table_new_full (GHashFunc hash_func,
|
|||||||
hash_table->values = hash_table->keys;
|
hash_table->values = hash_table->keys;
|
||||||
hash_table->hashes = g_new0 (guint, hash_table->size);
|
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.
|
||||||
|
*/
|
||||||
|
small = FALSE;
|
||||||
|
|
||||||
#ifdef USE_SMALL_ARRAYS
|
#ifdef USE_SMALL_ARRAYS
|
||||||
hash_table->have_big_keys = FALSE;
|
small = TRUE;
|
||||||
hash_table->have_big_values = FALSE;
|
|
||||||
#else
|
# ifdef ENABLE_VALGRIND
|
||||||
hash_table->have_big_keys = TRUE;
|
if (RUNNING_ON_VALGRIND)
|
||||||
hash_table->have_big_values = TRUE;
|
small = FALSE;
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
hash_table->have_big_keys = !small;
|
||||||
|
hash_table->have_big_values = !small;
|
||||||
|
|
||||||
return hash_table;
|
return hash_table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user