Re: Bug#14412: g_list_find_custom inconsistent with GCompareFunc
- From: Sebastian Wilhelmi <wilhelmi ira uka de>
- To: 14412 bugs gnome org
- Cc: John Tunison <nosinut WIND REM CMU EDU>, Gtk Development List <gtk-devel-list gnome org>
- Subject: Re: Bug#14412: g_list_find_custom inconsistent with GCompareFunc
- Date: Thu, 26 Oct 2000 15:25:03 +0200
Hi John,
> Description:
> The glib API says of g_list_find_custom, "It iterates over the list,
> calling the given function which should return 0 when the desired
> element is found.
That has also bugged me for a while. So I introduced another Function Type:
typedef gboolean (*GEqualFunc) (gconstpointer a, gconstpointer b);
That allows us to differentiate the (so far) two meanings of GCompareFunc at
the API level. a GCompareFunc works like strcmp and a GEqualFunc returns TRUE
for equal values. I havn't yet updated the Documentation, but I'll do that,
when I'm going to commit.
If no-one objects, I'll commit the attached patch next week. Note, that this
won't break any code, as gint and gboolean are the same.
Bye,
Sebastian
--
Sebastian Wilhelmi | här ovanför alla molnen
mailto:wilhelmi ira uka de | är himmlen så förunderligt blå
http://goethe.ira.uka.de/~wilhelmi |
Index: gcache.c
===================================================================
RCS file: /cvs/gnome/glib/gcache.c,v
retrieving revision 1.9
diff -u -b -B -r1.9 gcache.c
--- gcache.c 2000/07/26 11:01:59 1.9
+++ gcache.c 2000/10/26 13:16:20
@@ -77,7 +77,7 @@
GCacheDestroyFunc key_destroy_func,
GHashFunc hash_key_func,
GHashFunc hash_value_func,
- GCompareFunc key_compare_func)
+ GEqualFunc key_compare_func)
{
GRealCache *cache;
Index: gcache.h
===================================================================
RCS file: /cvs/gnome/glib/gcache.h,v
retrieving revision 1.1
diff -u -b -B -r1.1 gcache.h
--- gcache.h 2000/10/12 11:52:07 1.1
+++ gcache.h 2000/10/26 13:16:20
@@ -45,7 +45,7 @@
GCacheDestroyFunc key_destroy_func,
GHashFunc hash_key_func,
GHashFunc hash_value_func,
- GCompareFunc key_compare_func);
+ GEqualFunc key_compare_func);
void g_cache_destroy (GCache *cache);
gpointer g_cache_insert (GCache *cache,
gpointer key);
Index: ghash.c
===================================================================
RCS file: /cvs/gnome/glib/ghash.c,v
retrieving revision 1.20
diff -u -b -B -r1.20 ghash.c
--- ghash.c 2000/07/26 11:01:59 1.20
+++ ghash.c 2000/10/26 13:16:21
@@ -50,7 +50,7 @@
gint nnodes;
GHashNode **nodes;
GHashFunc hash_func;
- GCompareFunc key_compare_func;
+ GEqualFunc key_compare_func;
};
@@ -71,7 +71,7 @@
GHashTable*
g_hash_table_new (GHashFunc hash_func,
- GCompareFunc key_compare_func)
+ GEqualFunc key_compare_func)
{
GHashTable *hash_table;
guint i;
Index: ghash.h
===================================================================
RCS file: /cvs/gnome/glib/ghash.h,v
retrieving revision 1.1
diff -u -b -B -r1.1 ghash.h
--- ghash.h 2000/10/12 11:52:07 1.1
+++ ghash.h 2000/10/26 13:16:21
@@ -40,7 +40,7 @@
/* Hash tables
*/
GHashTable* g_hash_table_new (GHashFunc hash_func,
- GCompareFunc key_compare_func);
+ GEqualFunc key_compare_func);
void g_hash_table_destroy (GHashTable *hash_table);
void g_hash_table_insert (GHashTable *hash_table,
gpointer key,
@@ -72,7 +72,7 @@
gconstpointer v2);
guint g_str_hash (gconstpointer v);
-gint g_int_equal (gconstpointer v,
+gboolean g_int_equal (gconstpointer v,
gconstpointer v2) G_GNUC_CONST;
guint g_int_hash (gconstpointer v) G_GNUC_CONST;
@@ -83,7 +83,7 @@
* same effect as passing g_direct_hash().
*/
guint g_direct_hash (gconstpointer v) G_GNUC_CONST;
-gint g_direct_equal (gconstpointer v,
+gboolean g_direct_equal (gconstpointer v,
gconstpointer v2) G_GNUC_CONST;
G_END_DECLS
Index: grel.c
===================================================================
RCS file: /cvs/gnome/glib/grel.c,v
retrieving revision 1.8
diff -u -b -B -r1.8 grel.c
--- grel.c 2000/07/26 11:01:59 1.8
+++ grel.c 2000/10/26 13:16:21
@@ -85,7 +85,7 @@
return NULL;
}
-static GCompareFunc
+static GEqualFunc
tuple_equal (gint fields)
{
switch (fields)
@@ -150,7 +150,7 @@
g_relation_index (GRelation *relation,
gint field,
GHashFunc hash_func,
- GCompareFunc key_compare_func)
+ GEqualFunc key_compare_func)
{
GRealRelation *rel = (GRealRelation *) relation;
Index: grel.h
===================================================================
RCS file: /cvs/gnome/glib/grel.h,v
retrieving revision 1.1
diff -u -b -B -r1.1 grel.h
--- grel.h 2000/10/12 11:52:07 1.1
+++ grel.h 2000/10/26 13:16:21
@@ -67,7 +67,7 @@
void g_relation_index (GRelation *relation,
gint field,
GHashFunc hash_func,
- GCompareFunc key_compare_func);
+ GEqualFunc key_compare_func);
void g_relation_insert (GRelation *relation,
...);
gint g_relation_delete (GRelation *relation,
Index: gscanner.c
===================================================================
RCS file: /cvs/gnome/glib/gscanner.c,v
retrieving revision 1.27
diff -u -b -B -r1.27 gscanner.c
--- gscanner.c 2000/07/26 11:01:59 1.27
+++ gscanner.c 2000/10/26 13:16:21
@@ -127,7 +127,7 @@
GScannerKey* g_scanner_lookup_internal (GScanner *scanner,
guint scope_id,
const gchar *symbol);
-static gint g_scanner_key_equal (gconstpointer v1,
+static gboolean g_scanner_key_equal (gconstpointer v1,
gconstpointer v2);
static guint g_scanner_key_hash (gconstpointer v);
static void g_scanner_get_token_ll (GScanner *scanner,
@@ -346,7 +346,7 @@
}
}
-static gint
+static gboolean
g_scanner_key_equal (gconstpointer v1,
gconstpointer v2)
{
Index: gtypes.h
===================================================================
RCS file: /cvs/gnome/glib/gtypes.h,v
retrieving revision 1.2
diff -u -b -B -r1.2 gtypes.h
--- gtypes.h 2000/10/13 08:16:54 1.2
+++ gtypes.h 2000/10/26 13:16:21
@@ -69,6 +69,8 @@
typedef gint (*GCompareFunc) (gconstpointer a,
gconstpointer b);
+typedef gboolean (*GEqualFunc) (gconstpointer a,
+ gconstpointer b);
typedef void (*GDestroyNotify) (gpointer data);
typedef void (*GFunc) (gpointer data,
gpointer user_data);
Index: gutils.c
===================================================================
RCS file: /cvs/gnome/glib/gutils.c,v
retrieving revision 1.70
diff -u -b -B -r1.70 gutils.c
--- gutils.c 2000/10/09 16:24:56 1.70
+++ gutils.c 2000/10/26 13:16:21
@@ -917,14 +917,14 @@
return GPOINTER_TO_UINT (v);
}
-gint
+gboolean
g_direct_equal (gconstpointer v1,
gconstpointer v2)
{
return v1 == v2;
}
-gint
+gboolean
g_int_equal (gconstpointer v1,
gconstpointer v2)
{
Index: testglib.c
===================================================================
RCS file: /cvs/gnome/glib/testglib.c,v
retrieving revision 1.38
diff -u -b -B -r1.38 testglib.c
--- testglib.c 2000/09/07 23:08:25 1.38
+++ testglib.c 2000/10/26 13:16:21
@@ -238,7 +238,7 @@
return (guint) *((const gint*) key);
}
-static gint
+static gboolean
my_hash_compare (gconstpointer a,
gconstpointer b)
{
Index: gobject/gparam.c
===================================================================
RCS file: /cvs/gnome/glib/gobject/gparam.c,v
retrieving revision 1.5
diff -u -b -B -r1.5 gparam.c
--- gobject/gparam.c 2000/10/25 20:36:35 1.5
+++ gobject/gparam.c 2000/10/26 13:16:28
@@ -286,7 +286,7 @@
return h;
}
-static gint
+static gboolean
param_spec_equals (gconstpointer key_spec_1,
gconstpointer key_spec_2)
{
Index: gobject/gvalue.c
===================================================================
RCS file: /cvs/gnome/glib/gobject/gvalue.c,v
retrieving revision 1.4
diff -u -b -B -r1.4 gvalue.c
--- gobject/gvalue.c 2000/10/25 20:36:35 1.4
+++ gobject/gvalue.c 2000/10/26 13:16:28
@@ -142,7 +142,7 @@
value_table->value_init (value);
}
-static gint
+static gboolean
exchange_entries_equal (gconstpointer v1,
gconstpointer v2)
{
Index: tests/hash-test.c
===================================================================
RCS file: /cvs/gnome/glib/tests/hash-test.c,v
retrieving revision 1.6
diff -u -b -B -r1.6 hash-test.c
--- tests/hash-test.c 2000/07/26 11:02:02 1.6
+++ tests/hash-test.c 2000/10/26 13:16:28
@@ -84,7 +84,7 @@
return (guint) *((const gint*) key);
}
-static gint
+static gboolean
my_hash_compare (gconstpointer a,
gconstpointer b)
{
@@ -160,11 +160,9 @@
}
-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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]