mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-02 15:33:39 +02:00
Introduced new function type GEqualFunc to return TRUE for equal params.
2000-10-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de> * gcache.h, gcache.c, ghash.h, ghash.c, grel.c, grel.h, gtypes.h: Introduced new function type GEqualFunc to return TRUE for equal params. This is now used instead of GCompareFunc (which should work akin to strcmp) here. This kind of fixes Bug #14412. Note that technically GCompareFunc and GEqualFunc are still the same types, as gint == gboolean. * ghash.h, gutils.c: g_int_equal and g_direct_equal now return gboolean to be really become GEqualFunc. * gscanner.c, testglib.c, tests/hash-test.c: Some tiny changes to follow the above change.
This commit is contained in:
committed by
Sebastian Wilhelmi
parent
d42361a6e3
commit
267b681370
@@ -84,9 +84,9 @@ my_hash (gconstpointer key)
|
||||
return (guint) *((const gint*) key);
|
||||
}
|
||||
|
||||
static gint
|
||||
my_hash_compare (gconstpointer a,
|
||||
gconstpointer b)
|
||||
static gboolean
|
||||
my_hash_equal (gconstpointer a,
|
||||
gconstpointer b)
|
||||
{
|
||||
return *((const gint*) a) == *((const gint*) b);
|
||||
}
|
||||
@@ -160,11 +160,9 @@ static guint honeyman_hash(gconstpointer key)
|
||||
}
|
||||
|
||||
|
||||
static gint second_hash_cmp (gconstpointer a, gconstpointer b)
|
||||
static gboolean second_hash_cmp (gconstpointer a, gconstpointer b)
|
||||
{
|
||||
gint rc = (strcmp (a, b) == 0);
|
||||
|
||||
return rc;
|
||||
return (strcmp (a, b) == 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -336,7 +334,7 @@ main (int argc,
|
||||
GHashTable *hash_table;
|
||||
gint i;
|
||||
|
||||
hash_table = g_hash_table_new (my_hash, my_hash_compare);
|
||||
hash_table = g_hash_table_new (my_hash, my_hash_equal);
|
||||
for (i = 0; i < 10000; i++)
|
||||
{
|
||||
array[i] = i;
|
||||
|
@@ -238,9 +238,9 @@ my_hash (gconstpointer key)
|
||||
return (guint) *((const gint*) key);
|
||||
}
|
||||
|
||||
static gint
|
||||
my_hash_compare (gconstpointer a,
|
||||
gconstpointer b)
|
||||
static gboolean
|
||||
my_hash_equal (gconstpointer a,
|
||||
gconstpointer b)
|
||||
{
|
||||
return *((const gint*) a) == *((const gint*) b);
|
||||
}
|
||||
@@ -617,7 +617,7 @@ main (int argc,
|
||||
|
||||
g_print ("checking hash tables...");
|
||||
|
||||
hash_table = g_hash_table_new (my_hash, my_hash_compare);
|
||||
hash_table = g_hash_table_new (my_hash, my_hash_equal);
|
||||
for (i = 0; i < 10000; i++)
|
||||
{
|
||||
array[i] = i;
|
||||
|
Reference in New Issue
Block a user