mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-26 07:26:15 +01:00
Fix global variable name hidden by local variables in glib/tests/hash.c
This commit is contained in:
parent
479fcb40c0
commit
becce7742c
@ -34,9 +34,7 @@
|
|||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
|
static int global_array[10000];
|
||||||
|
|
||||||
int array[10000];
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
fill_hash_table_and_array (GHashTable *hash_table)
|
fill_hash_table_and_array (GHashTable *hash_table)
|
||||||
@ -45,8 +43,8 @@ fill_hash_table_and_array (GHashTable *hash_table)
|
|||||||
|
|
||||||
for (i = 0; i < 10000; i++)
|
for (i = 0; i < 10000; i++)
|
||||||
{
|
{
|
||||||
array[i] = i;
|
global_array[i] = i;
|
||||||
g_hash_table_insert (hash_table, &array[i], &array[i]);
|
g_hash_table_insert (hash_table, &global_array[i], &global_array[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -641,7 +639,7 @@ test_hash_misc (void)
|
|||||||
verify_result_array (result_array);
|
verify_result_array (result_array);
|
||||||
|
|
||||||
for (i = 0; i < 10000; i++)
|
for (i = 0; i < 10000; i++)
|
||||||
g_hash_table_remove (hash_table, &array[i]);
|
g_hash_table_remove (hash_table, &global_array[i]);
|
||||||
|
|
||||||
fill_hash_table_and_array (hash_table);
|
fill_hash_table_and_array (hash_table);
|
||||||
|
|
||||||
@ -971,14 +969,14 @@ set_ref_hash_test (void)
|
|||||||
key_unref (key2);
|
key_unref (key2);
|
||||||
}
|
}
|
||||||
|
|
||||||
GHashTable *h;
|
static GHashTable *global_hashtable;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
gchar *string;
|
gchar *string;
|
||||||
gboolean freed;
|
gboolean freed;
|
||||||
} FakeFreeData;
|
} FakeFreeData;
|
||||||
|
|
||||||
GPtrArray *fake_free_data;
|
static GPtrArray *fake_free_data;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
fake_free (gpointer dead)
|
fake_free (gpointer dead)
|
||||||
@ -1003,7 +1001,7 @@ fake_free (gpointer dead)
|
|||||||
static void
|
static void
|
||||||
value_destroy_insert (gpointer value)
|
value_destroy_insert (gpointer value)
|
||||||
{
|
{
|
||||||
g_hash_table_remove_all (h);
|
g_hash_table_remove_all (global_hashtable);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1016,44 +1014,44 @@ test_destroy_modify (void)
|
|||||||
|
|
||||||
fake_free_data = g_ptr_array_new ();
|
fake_free_data = g_ptr_array_new ();
|
||||||
|
|
||||||
h = g_hash_table_new_full (g_str_hash, g_str_equal, fake_free, value_destroy_insert);
|
global_hashtable = g_hash_table_new_full (g_str_hash, g_str_equal, fake_free, value_destroy_insert);
|
||||||
|
|
||||||
ffd = g_new0 (FakeFreeData, 1);
|
ffd = g_new0 (FakeFreeData, 1);
|
||||||
ffd->string = g_strdup ("a");
|
ffd->string = g_strdup ("a");
|
||||||
g_ptr_array_add (fake_free_data, ffd);
|
g_ptr_array_add (fake_free_data, ffd);
|
||||||
g_hash_table_insert (h, ffd->string, "b");
|
g_hash_table_insert (global_hashtable, ffd->string, "b");
|
||||||
|
|
||||||
ffd = g_new0 (FakeFreeData, 1);
|
ffd = g_new0 (FakeFreeData, 1);
|
||||||
ffd->string = g_strdup ("c");
|
ffd->string = g_strdup ("c");
|
||||||
g_ptr_array_add (fake_free_data, ffd);
|
g_ptr_array_add (fake_free_data, ffd);
|
||||||
g_hash_table_insert (h, ffd->string, "d");
|
g_hash_table_insert (global_hashtable, ffd->string, "d");
|
||||||
|
|
||||||
ffd = g_new0 (FakeFreeData, 1);
|
ffd = g_new0 (FakeFreeData, 1);
|
||||||
ffd->string = g_strdup ("e");
|
ffd->string = g_strdup ("e");
|
||||||
g_ptr_array_add (fake_free_data, ffd);
|
g_ptr_array_add (fake_free_data, ffd);
|
||||||
g_hash_table_insert (h, ffd->string, "f");
|
g_hash_table_insert (global_hashtable, ffd->string, "f");
|
||||||
|
|
||||||
ffd = g_new0 (FakeFreeData, 1);
|
ffd = g_new0 (FakeFreeData, 1);
|
||||||
ffd->string = g_strdup ("g");
|
ffd->string = g_strdup ("g");
|
||||||
g_ptr_array_add (fake_free_data, ffd);
|
g_ptr_array_add (fake_free_data, ffd);
|
||||||
g_hash_table_insert (h, ffd->string, "h");
|
g_hash_table_insert (global_hashtable, ffd->string, "h");
|
||||||
|
|
||||||
ffd = g_new0 (FakeFreeData, 1);
|
ffd = g_new0 (FakeFreeData, 1);
|
||||||
ffd->string = g_strdup ("h");
|
ffd->string = g_strdup ("h");
|
||||||
g_ptr_array_add (fake_free_data, ffd);
|
g_ptr_array_add (fake_free_data, ffd);
|
||||||
g_hash_table_insert (h, ffd->string, "k");
|
g_hash_table_insert (global_hashtable, ffd->string, "k");
|
||||||
|
|
||||||
ffd = g_new0 (FakeFreeData, 1);
|
ffd = g_new0 (FakeFreeData, 1);
|
||||||
ffd->string = g_strdup ("a");
|
ffd->string = g_strdup ("a");
|
||||||
g_ptr_array_add (fake_free_data, ffd);
|
g_ptr_array_add (fake_free_data, ffd);
|
||||||
g_hash_table_insert (h, ffd->string, "c");
|
g_hash_table_insert (global_hashtable, ffd->string, "c");
|
||||||
|
|
||||||
g_hash_table_remove (h, "c");
|
g_hash_table_remove (global_hashtable, "c");
|
||||||
|
|
||||||
/* that removed everything... */
|
/* that removed everything... */
|
||||||
for (i = 0; i < fake_free_data->len; i++)
|
for (i = 0; i < fake_free_data->len; i++)
|
||||||
{
|
{
|
||||||
FakeFreeData *ffd = g_ptr_array_index (fake_free_data, i);
|
ffd = g_ptr_array_index (fake_free_data, i);
|
||||||
|
|
||||||
g_assert (ffd->freed);
|
g_assert (ffd->freed);
|
||||||
g_free (ffd->string);
|
g_free (ffd->string);
|
||||||
@ -1063,9 +1061,9 @@ test_destroy_modify (void)
|
|||||||
g_ptr_array_unref (fake_free_data);
|
g_ptr_array_unref (fake_free_data);
|
||||||
|
|
||||||
/* ... so this is a no-op */
|
/* ... so this is a no-op */
|
||||||
g_hash_table_remove (h, "e");
|
g_hash_table_remove (global_hashtable, "e");
|
||||||
|
|
||||||
g_hash_table_unref (h);
|
g_hash_table_unref (global_hashtable);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
Loading…
Reference in New Issue
Block a user