Introduced new function type GEqualFunc to return TRUE for equal params.
authorSebastian Wilhelmi <wilhelmi@ira.uka.de>
Mon, 30 Oct 2000 14:34:52 +0000 (14:34 +0000)
committerSebastian Wilhelmi <wilhelmi@src.gnome.org>
Mon, 30 Oct 2000 14:34:52 +0000 (14:34 +0000)
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.

29 files changed:
ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gcache.c
gcache.h
ghash.c
ghash.h
glib/gcache.c
glib/gcache.h
glib/ghash.c
glib/ghash.h
glib/grel.c
glib/grel.h
glib/gscanner.c
glib/gtypes.h
glib/gutils.c
grel.c
grel.h
gscanner.c
gtypes.h
gutils.c
testglib.c
tests/hash-test.c
tests/testglib.c

index b42044f..7fedca6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+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.
+
 2000-10-27  Tor Lillqvist  <tml@iki.fi>
 
        * makefile.{mingw,msc}.in (glib_OBJECTS): Add gmarkup.
index b42044f..7fedca6 100644 (file)
@@ -1,3 +1,18 @@
+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.
+
 2000-10-27  Tor Lillqvist  <tml@iki.fi>
 
        * makefile.{mingw,msc}.in (glib_OBJECTS): Add gmarkup.
index b42044f..7fedca6 100644 (file)
@@ -1,3 +1,18 @@
+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.
+
 2000-10-27  Tor Lillqvist  <tml@iki.fi>
 
        * makefile.{mingw,msc}.in (glib_OBJECTS): Add gmarkup.
index b42044f..7fedca6 100644 (file)
@@ -1,3 +1,18 @@
+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.
+
 2000-10-27  Tor Lillqvist  <tml@iki.fi>
 
        * makefile.{mingw,msc}.in (glib_OBJECTS): Add gmarkup.
index b42044f..7fedca6 100644 (file)
@@ -1,3 +1,18 @@
+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.
+
 2000-10-27  Tor Lillqvist  <tml@iki.fi>
 
        * makefile.{mingw,msc}.in (glib_OBJECTS): Add gmarkup.
index b42044f..7fedca6 100644 (file)
@@ -1,3 +1,18 @@
+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.
+
 2000-10-27  Tor Lillqvist  <tml@iki.fi>
 
        * makefile.{mingw,msc}.in (glib_OBJECTS): Add gmarkup.
index b42044f..7fedca6 100644 (file)
@@ -1,3 +1,18 @@
+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.
+
 2000-10-27  Tor Lillqvist  <tml@iki.fi>
 
        * makefile.{mingw,msc}.in (glib_OBJECTS): Add gmarkup.
index b42044f..7fedca6 100644 (file)
@@ -1,3 +1,18 @@
+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.
+
 2000-10-27  Tor Lillqvist  <tml@iki.fi>
 
        * makefile.{mingw,msc}.in (glib_OBJECTS): Add gmarkup.
index 1b5518e..5a06e0e 100644 (file)
--- a/gcache.c
+++ b/gcache.c
@@ -77,7 +77,7 @@ g_cache_new (GCacheNewFunc      value_new_func,
             GCacheDestroyFunc  key_destroy_func,
             GHashFunc          hash_key_func,
             GHashFunc          hash_value_func,
-            GCompareFunc       key_compare_func)
+            GEqualFunc         key_equal_func)
 {
   GRealCache *cache;
 
@@ -87,14 +87,14 @@ g_cache_new (GCacheNewFunc      value_new_func,
   g_return_val_if_fail (key_destroy_func != NULL, NULL);
   g_return_val_if_fail (hash_key_func != NULL, NULL);
   g_return_val_if_fail (hash_value_func != NULL, NULL);
-  g_return_val_if_fail (key_compare_func != NULL, NULL);
+  g_return_val_if_fail (key_equal_func != NULL, NULL);
 
   cache = g_new (GRealCache, 1);
   cache->value_new_func = value_new_func;
   cache->value_destroy_func = value_destroy_func;
   cache->key_dup_func = key_dup_func;
   cache->key_destroy_func = key_destroy_func;
-  cache->key_table = g_hash_table_new (hash_key_func, key_compare_func);
+  cache->key_table = g_hash_table_new (hash_key_func, key_equal_func);
   cache->value_table = g_hash_table_new (hash_value_func, NULL);
 
   return (GCache*) cache;
index 10b5c91..74ef5b6 100644 (file)
--- a/gcache.h
+++ b/gcache.h
@@ -45,7 +45,7 @@ GCache*  g_cache_new           (GCacheNewFunc      value_new_func,
                                 GCacheDestroyFunc  key_destroy_func,
                                 GHashFunc          hash_key_func,
                                 GHashFunc          hash_value_func,
-                                GCompareFunc       key_compare_func);
+                                GEqualFunc         key_equal_func);
 void     g_cache_destroy       (GCache            *cache);
 gpointer g_cache_insert        (GCache            *cache,
                                 gpointer           key);
diff --git a/ghash.c b/ghash.c
index a664e87..d35df18 100644 (file)
--- a/ghash.c
+++ b/ghash.c
@@ -50,7 +50,7 @@ struct _GHashTable
   gint nnodes;
   GHashNode **nodes;
   GHashFunc hash_func;
-  GCompareFunc key_compare_func;
+  GEqualFunc key_equal_func;
 };
 
 
@@ -71,7 +71,7 @@ static GHashNode *node_free_list = NULL;
 
 GHashTable*
 g_hash_table_new (GHashFunc    hash_func,
-                 GCompareFunc key_compare_func)
+                 GEqualFunc   key_equal_func)
 {
   GHashTable *hash_table;
   guint i;
@@ -80,7 +80,7 @@ g_hash_table_new (GHashFunc    hash_func,
   hash_table->size = HASH_TABLE_MIN_SIZE;
   hash_table->nnodes = 0;
   hash_table->hash_func = hash_func ? hash_func : g_direct_hash;
-  hash_table->key_compare_func = key_compare_func;
+  hash_table->key_equal_func = key_equal_func;
   hash_table->nodes = g_new (GHashNode*, hash_table->size);
   
   for (i = 0; i < hash_table->size; i++)
@@ -114,11 +114,11 @@ g_hash_table_lookup_node (GHashTable      *hash_table,
   
   /* Hash table lookup needs to be fast.
    *  We therefore remove the extra conditional of testing
-   *  whether to call the key_compare_func or not from
+   *  whether to call the key_equal_func or not from
    *  the inner loop.
    */
-  if (hash_table->key_compare_func)
-    while (*node && !(*hash_table->key_compare_func) ((*node)->key, key))
+  if (hash_table->key_equal_func)
+    while (*node && !(*hash_table->key_equal_func) ((*node)->key, key))
       node = &(*node)->next;
   else
     while (*node && (*node)->key != key)
diff --git a/ghash.h b/ghash.h
index 280ad60..2f64131 100644 (file)
--- a/ghash.h
+++ b/ghash.h
@@ -40,7 +40,7 @@ typedef gboolean      (*GHRFunc)              (gpointer       key,
 /* Hash tables
  */
 GHashTable* g_hash_table_new           (GHashFunc       hash_func,
-                                        GCompareFunc    key_compare_func);
+                                        GEqualFunc      key_equal_func);
 void       g_hash_table_destroy        (GHashTable     *hash_table);
 void       g_hash_table_insert         (GHashTable     *hash_table,
                                         gpointer        key,
@@ -72,7 +72,7 @@ gboolean g_str_equal (gconstpointer   v,
                       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;
 
@@ -82,9 +82,9 @@ guint    g_int_hash  (gconstpointer   v) G_GNUC_CONST;
  * passing NULL into g_hash_table_new() as GHashFunc has the
  * same effect as passing g_direct_hash().
  */
-guint g_direct_hash  (gconstpointer v) G_GNUC_CONST;
-gint  g_direct_equal (gconstpointer v,
-                      gconstpointer v2) G_GNUC_CONST;
+guint    g_direct_hash  (gconstpointer v) G_GNUC_CONST;
+gboolean g_direct_equal (gconstpointer v,
+                         gconstpointer v2) G_GNUC_CONST;
 
 G_END_DECLS
 
index 1b5518e..5a06e0e 100644 (file)
@@ -77,7 +77,7 @@ g_cache_new (GCacheNewFunc      value_new_func,
             GCacheDestroyFunc  key_destroy_func,
             GHashFunc          hash_key_func,
             GHashFunc          hash_value_func,
-            GCompareFunc       key_compare_func)
+            GEqualFunc         key_equal_func)
 {
   GRealCache *cache;
 
@@ -87,14 +87,14 @@ g_cache_new (GCacheNewFunc      value_new_func,
   g_return_val_if_fail (key_destroy_func != NULL, NULL);
   g_return_val_if_fail (hash_key_func != NULL, NULL);
   g_return_val_if_fail (hash_value_func != NULL, NULL);
-  g_return_val_if_fail (key_compare_func != NULL, NULL);
+  g_return_val_if_fail (key_equal_func != NULL, NULL);
 
   cache = g_new (GRealCache, 1);
   cache->value_new_func = value_new_func;
   cache->value_destroy_func = value_destroy_func;
   cache->key_dup_func = key_dup_func;
   cache->key_destroy_func = key_destroy_func;
-  cache->key_table = g_hash_table_new (hash_key_func, key_compare_func);
+  cache->key_table = g_hash_table_new (hash_key_func, key_equal_func);
   cache->value_table = g_hash_table_new (hash_value_func, NULL);
 
   return (GCache*) cache;
index 10b5c91..74ef5b6 100644 (file)
@@ -45,7 +45,7 @@ GCache*  g_cache_new           (GCacheNewFunc      value_new_func,
                                 GCacheDestroyFunc  key_destroy_func,
                                 GHashFunc          hash_key_func,
                                 GHashFunc          hash_value_func,
-                                GCompareFunc       key_compare_func);
+                                GEqualFunc         key_equal_func);
 void     g_cache_destroy       (GCache            *cache);
 gpointer g_cache_insert        (GCache            *cache,
                                 gpointer           key);
index a664e87..d35df18 100644 (file)
@@ -50,7 +50,7 @@ struct _GHashTable
   gint nnodes;
   GHashNode **nodes;
   GHashFunc hash_func;
-  GCompareFunc key_compare_func;
+  GEqualFunc key_equal_func;
 };
 
 
@@ -71,7 +71,7 @@ static GHashNode *node_free_list = NULL;
 
 GHashTable*
 g_hash_table_new (GHashFunc    hash_func,
-                 GCompareFunc key_compare_func)
+                 GEqualFunc   key_equal_func)
 {
   GHashTable *hash_table;
   guint i;
@@ -80,7 +80,7 @@ g_hash_table_new (GHashFunc    hash_func,
   hash_table->size = HASH_TABLE_MIN_SIZE;
   hash_table->nnodes = 0;
   hash_table->hash_func = hash_func ? hash_func : g_direct_hash;
-  hash_table->key_compare_func = key_compare_func;
+  hash_table->key_equal_func = key_equal_func;
   hash_table->nodes = g_new (GHashNode*, hash_table->size);
   
   for (i = 0; i < hash_table->size; i++)
@@ -114,11 +114,11 @@ g_hash_table_lookup_node (GHashTable      *hash_table,
   
   /* Hash table lookup needs to be fast.
    *  We therefore remove the extra conditional of testing
-   *  whether to call the key_compare_func or not from
+   *  whether to call the key_equal_func or not from
    *  the inner loop.
    */
-  if (hash_table->key_compare_func)
-    while (*node && !(*hash_table->key_compare_func) ((*node)->key, key))
+  if (hash_table->key_equal_func)
+    while (*node && !(*hash_table->key_equal_func) ((*node)->key, key))
       node = &(*node)->next;
   else
     while (*node && (*node)->key != key)
index 280ad60..2f64131 100644 (file)
@@ -40,7 +40,7 @@ typedef gboolean      (*GHRFunc)              (gpointer       key,
 /* Hash tables
  */
 GHashTable* g_hash_table_new           (GHashFunc       hash_func,
-                                        GCompareFunc    key_compare_func);
+                                        GEqualFunc      key_equal_func);
 void       g_hash_table_destroy        (GHashTable     *hash_table);
 void       g_hash_table_insert         (GHashTable     *hash_table,
                                         gpointer        key,
@@ -72,7 +72,7 @@ gboolean g_str_equal (gconstpointer   v,
                       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;
 
@@ -82,9 +82,9 @@ guint    g_int_hash  (gconstpointer   v) G_GNUC_CONST;
  * passing NULL into g_hash_table_new() as GHashFunc has the
  * same effect as passing g_direct_hash().
  */
-guint g_direct_hash  (gconstpointer v) G_GNUC_CONST;
-gint  g_direct_equal (gconstpointer v,
-                      gconstpointer v2) G_GNUC_CONST;
+guint    g_direct_hash  (gconstpointer v) G_GNUC_CONST;
+gboolean g_direct_equal (gconstpointer v,
+                         gconstpointer v2) G_GNUC_CONST;
 
 G_END_DECLS
 
index 9e4f328..1e82b26 100644 (file)
@@ -85,7 +85,7 @@ tuple_hash (gint fields)
   return NULL;
 }
 
-static GCompareFunc
+static GEqualFunc
 tuple_equal (gint fields)
 {
   switch (fields)
@@ -150,7 +150,7 @@ void
 g_relation_index (GRelation   *relation,
                  gint         field,
                  GHashFunc    hash_func,
-                 GCompareFunc key_compare_func)
+                 GEqualFunc   key_equal_func)
 {
   GRealRelation *rel = (GRealRelation *) relation;
 
@@ -158,7 +158,7 @@ g_relation_index (GRelation   *relation,
   
   g_return_if_fail (rel->count == 0 && rel->hashed_tuple_tables[field] == NULL);
   
-  rel->hashed_tuple_tables[field] = g_hash_table_new (hash_func, key_compare_func);
+  rel->hashed_tuple_tables[field] = g_hash_table_new (hash_func, key_equal_func);
 }
 
 void
index 09b2e23..fcf8eab 100644 (file)
@@ -67,7 +67,7 @@ void       g_relation_destroy (GRelation   *relation);
 void       g_relation_index   (GRelation   *relation,
                                gint         field,
                                GHashFunc    hash_func,
-                               GCompareFunc key_compare_func);
+                               GEqualFunc   key_equal_func);
 void       g_relation_insert  (GRelation   *relation,
                                ...);
 gint       g_relation_delete  (GRelation   *relation,
index 8839dff..3291a8c 100644 (file)
@@ -127,7 +127,7 @@ static inline
 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 @@ g_scanner_warn (GScanner       *scanner,
     }
 }
 
-static gint
+static gboolean
 g_scanner_key_equal (gconstpointer v1,
                     gconstpointer v2)
 {
index cfe572b..5f7d493 100644 (file)
@@ -69,6 +69,8 @@ typedef const void *gconstpointer;
 
 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 4910beb..fac6737 100644 (file)
@@ -917,14 +917,14 @@ g_direct_hash (gconstpointer v)
   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)
 {
diff --git a/grel.c b/grel.c
index 9e4f328..1e82b26 100644 (file)
--- a/grel.c
+++ b/grel.c
@@ -85,7 +85,7 @@ tuple_hash (gint fields)
   return NULL;
 }
 
-static GCompareFunc
+static GEqualFunc
 tuple_equal (gint fields)
 {
   switch (fields)
@@ -150,7 +150,7 @@ void
 g_relation_index (GRelation   *relation,
                  gint         field,
                  GHashFunc    hash_func,
-                 GCompareFunc key_compare_func)
+                 GEqualFunc   key_equal_func)
 {
   GRealRelation *rel = (GRealRelation *) relation;
 
@@ -158,7 +158,7 @@ g_relation_index (GRelation   *relation,
   
   g_return_if_fail (rel->count == 0 && rel->hashed_tuple_tables[field] == NULL);
   
-  rel->hashed_tuple_tables[field] = g_hash_table_new (hash_func, key_compare_func);
+  rel->hashed_tuple_tables[field] = g_hash_table_new (hash_func, key_equal_func);
 }
 
 void
diff --git a/grel.h b/grel.h
index 09b2e23..fcf8eab 100644 (file)
--- a/grel.h
+++ b/grel.h
@@ -67,7 +67,7 @@ void       g_relation_destroy (GRelation   *relation);
 void       g_relation_index   (GRelation   *relation,
                                gint         field,
                                GHashFunc    hash_func,
-                               GCompareFunc key_compare_func);
+                               GEqualFunc   key_equal_func);
 void       g_relation_insert  (GRelation   *relation,
                                ...);
 gint       g_relation_delete  (GRelation   *relation,
index 8839dff..3291a8c 100644 (file)
@@ -127,7 +127,7 @@ static inline
 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 @@ g_scanner_warn (GScanner       *scanner,
     }
 }
 
-static gint
+static gboolean
 g_scanner_key_equal (gconstpointer v1,
                     gconstpointer v2)
 {
index cfe572b..5f7d493 100644 (file)
--- a/gtypes.h
+++ b/gtypes.h
@@ -69,6 +69,8 @@ typedef const void *gconstpointer;
 
 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 4910beb..fac6737 100644 (file)
--- a/gutils.c
+++ b/gutils.c
@@ -917,14 +917,14 @@ g_direct_hash (gconstpointer v)
   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 08b4c4b..cb8f50f 100644 (file)
@@ -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;
index bcd6ddb..f295d6a 100644 (file)
@@ -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;
index 08b4c4b..cb8f50f 100644 (file)
@@ -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;