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:
Sebastian Wilhelmi
2000-10-30 14:34:52 +00:00
committed by Sebastian Wilhelmi
parent d42361a6e3
commit 267b681370
29 changed files with 184 additions and 62 deletions

View 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> 2000-10-27 Tor Lillqvist <tml@iki.fi>
* makefile.{mingw,msc}.in (glib_OBJECTS): Add gmarkup. * makefile.{mingw,msc}.in (glib_OBJECTS): Add gmarkup.

View 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> 2000-10-27 Tor Lillqvist <tml@iki.fi>
* makefile.{mingw,msc}.in (glib_OBJECTS): Add gmarkup. * makefile.{mingw,msc}.in (glib_OBJECTS): Add gmarkup.

View 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> 2000-10-27 Tor Lillqvist <tml@iki.fi>
* makefile.{mingw,msc}.in (glib_OBJECTS): Add gmarkup. * makefile.{mingw,msc}.in (glib_OBJECTS): Add gmarkup.

View 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> 2000-10-27 Tor Lillqvist <tml@iki.fi>
* makefile.{mingw,msc}.in (glib_OBJECTS): Add gmarkup. * makefile.{mingw,msc}.in (glib_OBJECTS): Add gmarkup.

View 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> 2000-10-27 Tor Lillqvist <tml@iki.fi>
* makefile.{mingw,msc}.in (glib_OBJECTS): Add gmarkup. * makefile.{mingw,msc}.in (glib_OBJECTS): Add gmarkup.

View 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> 2000-10-27 Tor Lillqvist <tml@iki.fi>
* makefile.{mingw,msc}.in (glib_OBJECTS): Add gmarkup. * makefile.{mingw,msc}.in (glib_OBJECTS): Add gmarkup.

View 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> 2000-10-27 Tor Lillqvist <tml@iki.fi>
* makefile.{mingw,msc}.in (glib_OBJECTS): Add gmarkup. * makefile.{mingw,msc}.in (glib_OBJECTS): Add gmarkup.

View 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> 2000-10-27 Tor Lillqvist <tml@iki.fi>
* makefile.{mingw,msc}.in (glib_OBJECTS): Add gmarkup. * makefile.{mingw,msc}.in (glib_OBJECTS): Add gmarkup.

View File

@@ -77,7 +77,7 @@ g_cache_new (GCacheNewFunc value_new_func,
GCacheDestroyFunc key_destroy_func, GCacheDestroyFunc key_destroy_func,
GHashFunc hash_key_func, GHashFunc hash_key_func,
GHashFunc hash_value_func, GHashFunc hash_value_func,
GCompareFunc key_compare_func) GEqualFunc key_equal_func)
{ {
GRealCache *cache; 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 (key_destroy_func != NULL, NULL);
g_return_val_if_fail (hash_key_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 (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 = g_new (GRealCache, 1);
cache->value_new_func = value_new_func; cache->value_new_func = value_new_func;
cache->value_destroy_func = value_destroy_func; cache->value_destroy_func = value_destroy_func;
cache->key_dup_func = key_dup_func; cache->key_dup_func = key_dup_func;
cache->key_destroy_func = key_destroy_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); cache->value_table = g_hash_table_new (hash_value_func, NULL);
return (GCache*) cache; return (GCache*) cache;

View File

@@ -45,7 +45,7 @@ GCache* g_cache_new (GCacheNewFunc value_new_func,
GCacheDestroyFunc key_destroy_func, GCacheDestroyFunc key_destroy_func,
GHashFunc hash_key_func, GHashFunc hash_key_func,
GHashFunc hash_value_func, GHashFunc hash_value_func,
GCompareFunc key_compare_func); GEqualFunc key_equal_func);
void g_cache_destroy (GCache *cache); void g_cache_destroy (GCache *cache);
gpointer g_cache_insert (GCache *cache, gpointer g_cache_insert (GCache *cache,
gpointer key); gpointer key);

12
ghash.c
View File

@@ -50,7 +50,7 @@ struct _GHashTable
gint nnodes; gint nnodes;
GHashNode **nodes; GHashNode **nodes;
GHashFunc hash_func; GHashFunc hash_func;
GCompareFunc key_compare_func; GEqualFunc key_equal_func;
}; };
@@ -71,7 +71,7 @@ static GHashNode *node_free_list = NULL;
GHashTable* GHashTable*
g_hash_table_new (GHashFunc hash_func, g_hash_table_new (GHashFunc hash_func,
GCompareFunc key_compare_func) GEqualFunc key_equal_func)
{ {
GHashTable *hash_table; GHashTable *hash_table;
guint i; guint i;
@@ -80,7 +80,7 @@ g_hash_table_new (GHashFunc hash_func,
hash_table->size = HASH_TABLE_MIN_SIZE; hash_table->size = HASH_TABLE_MIN_SIZE;
hash_table->nnodes = 0; hash_table->nnodes = 0;
hash_table->hash_func = hash_func ? hash_func : g_direct_hash; 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); hash_table->nodes = g_new (GHashNode*, hash_table->size);
for (i = 0; i < hash_table->size; i++) 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. /* Hash table lookup needs to be fast.
* We therefore remove the extra conditional of testing * 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. * the inner loop.
*/ */
if (hash_table->key_compare_func) if (hash_table->key_equal_func)
while (*node && !(*hash_table->key_compare_func) ((*node)->key, key)) while (*node && !(*hash_table->key_equal_func) ((*node)->key, key))
node = &(*node)->next; node = &(*node)->next;
else else
while (*node && (*node)->key != key) while (*node && (*node)->key != key)

10
ghash.h
View File

@@ -40,7 +40,7 @@ typedef gboolean (*GHRFunc) (gpointer key,
/* Hash tables /* Hash tables
*/ */
GHashTable* g_hash_table_new (GHashFunc hash_func, 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_destroy (GHashTable *hash_table);
void g_hash_table_insert (GHashTable *hash_table, void g_hash_table_insert (GHashTable *hash_table,
gpointer key, gpointer key,
@@ -72,7 +72,7 @@ gboolean g_str_equal (gconstpointer v,
gconstpointer v2); gconstpointer v2);
guint g_str_hash (gconstpointer v); guint g_str_hash (gconstpointer v);
gint g_int_equal (gconstpointer v, gboolean g_int_equal (gconstpointer v,
gconstpointer v2) G_GNUC_CONST; gconstpointer v2) G_GNUC_CONST;
guint g_int_hash (gconstpointer v) 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 * passing NULL into g_hash_table_new() as GHashFunc has the
* same effect as passing g_direct_hash(). * same effect as passing g_direct_hash().
*/ */
guint g_direct_hash (gconstpointer v) G_GNUC_CONST; 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; gconstpointer v2) G_GNUC_CONST;
G_END_DECLS G_END_DECLS

View File

@@ -77,7 +77,7 @@ g_cache_new (GCacheNewFunc value_new_func,
GCacheDestroyFunc key_destroy_func, GCacheDestroyFunc key_destroy_func,
GHashFunc hash_key_func, GHashFunc hash_key_func,
GHashFunc hash_value_func, GHashFunc hash_value_func,
GCompareFunc key_compare_func) GEqualFunc key_equal_func)
{ {
GRealCache *cache; 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 (key_destroy_func != NULL, NULL);
g_return_val_if_fail (hash_key_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 (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 = g_new (GRealCache, 1);
cache->value_new_func = value_new_func; cache->value_new_func = value_new_func;
cache->value_destroy_func = value_destroy_func; cache->value_destroy_func = value_destroy_func;
cache->key_dup_func = key_dup_func; cache->key_dup_func = key_dup_func;
cache->key_destroy_func = key_destroy_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); cache->value_table = g_hash_table_new (hash_value_func, NULL);
return (GCache*) cache; return (GCache*) cache;

View File

@@ -45,7 +45,7 @@ GCache* g_cache_new (GCacheNewFunc value_new_func,
GCacheDestroyFunc key_destroy_func, GCacheDestroyFunc key_destroy_func,
GHashFunc hash_key_func, GHashFunc hash_key_func,
GHashFunc hash_value_func, GHashFunc hash_value_func,
GCompareFunc key_compare_func); GEqualFunc key_equal_func);
void g_cache_destroy (GCache *cache); void g_cache_destroy (GCache *cache);
gpointer g_cache_insert (GCache *cache, gpointer g_cache_insert (GCache *cache,
gpointer key); gpointer key);

View File

@@ -50,7 +50,7 @@ struct _GHashTable
gint nnodes; gint nnodes;
GHashNode **nodes; GHashNode **nodes;
GHashFunc hash_func; GHashFunc hash_func;
GCompareFunc key_compare_func; GEqualFunc key_equal_func;
}; };
@@ -71,7 +71,7 @@ static GHashNode *node_free_list = NULL;
GHashTable* GHashTable*
g_hash_table_new (GHashFunc hash_func, g_hash_table_new (GHashFunc hash_func,
GCompareFunc key_compare_func) GEqualFunc key_equal_func)
{ {
GHashTable *hash_table; GHashTable *hash_table;
guint i; guint i;
@@ -80,7 +80,7 @@ g_hash_table_new (GHashFunc hash_func,
hash_table->size = HASH_TABLE_MIN_SIZE; hash_table->size = HASH_TABLE_MIN_SIZE;
hash_table->nnodes = 0; hash_table->nnodes = 0;
hash_table->hash_func = hash_func ? hash_func : g_direct_hash; 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); hash_table->nodes = g_new (GHashNode*, hash_table->size);
for (i = 0; i < hash_table->size; i++) 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. /* Hash table lookup needs to be fast.
* We therefore remove the extra conditional of testing * 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. * the inner loop.
*/ */
if (hash_table->key_compare_func) if (hash_table->key_equal_func)
while (*node && !(*hash_table->key_compare_func) ((*node)->key, key)) while (*node && !(*hash_table->key_equal_func) ((*node)->key, key))
node = &(*node)->next; node = &(*node)->next;
else else
while (*node && (*node)->key != key) while (*node && (*node)->key != key)

View File

@@ -40,7 +40,7 @@ typedef gboolean (*GHRFunc) (gpointer key,
/* Hash tables /* Hash tables
*/ */
GHashTable* g_hash_table_new (GHashFunc hash_func, 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_destroy (GHashTable *hash_table);
void g_hash_table_insert (GHashTable *hash_table, void g_hash_table_insert (GHashTable *hash_table,
gpointer key, gpointer key,
@@ -72,7 +72,7 @@ gboolean g_str_equal (gconstpointer v,
gconstpointer v2); gconstpointer v2);
guint g_str_hash (gconstpointer v); guint g_str_hash (gconstpointer v);
gint g_int_equal (gconstpointer v, gboolean g_int_equal (gconstpointer v,
gconstpointer v2) G_GNUC_CONST; gconstpointer v2) G_GNUC_CONST;
guint g_int_hash (gconstpointer v) 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 * passing NULL into g_hash_table_new() as GHashFunc has the
* same effect as passing g_direct_hash(). * same effect as passing g_direct_hash().
*/ */
guint g_direct_hash (gconstpointer v) G_GNUC_CONST; 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; gconstpointer v2) G_GNUC_CONST;
G_END_DECLS G_END_DECLS

View File

@@ -85,7 +85,7 @@ tuple_hash (gint fields)
return NULL; return NULL;
} }
static GCompareFunc static GEqualFunc
tuple_equal (gint fields) tuple_equal (gint fields)
{ {
switch (fields) switch (fields)
@@ -150,7 +150,7 @@ void
g_relation_index (GRelation *relation, g_relation_index (GRelation *relation,
gint field, gint field,
GHashFunc hash_func, GHashFunc hash_func,
GCompareFunc key_compare_func) GEqualFunc key_equal_func)
{ {
GRealRelation *rel = (GRealRelation *) relation; 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); 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 void

View File

@@ -67,7 +67,7 @@ void g_relation_destroy (GRelation *relation);
void g_relation_index (GRelation *relation, void g_relation_index (GRelation *relation,
gint field, gint field,
GHashFunc hash_func, GHashFunc hash_func,
GCompareFunc key_compare_func); GEqualFunc key_equal_func);
void g_relation_insert (GRelation *relation, void g_relation_insert (GRelation *relation,
...); ...);
gint g_relation_delete (GRelation *relation, gint g_relation_delete (GRelation *relation,

View File

@@ -127,7 +127,7 @@ static inline
GScannerKey* g_scanner_lookup_internal (GScanner *scanner, GScannerKey* g_scanner_lookup_internal (GScanner *scanner,
guint scope_id, guint scope_id,
const gchar *symbol); const gchar *symbol);
static gint g_scanner_key_equal (gconstpointer v1, static gboolean g_scanner_key_equal (gconstpointer v1,
gconstpointer v2); gconstpointer v2);
static guint g_scanner_key_hash (gconstpointer v); static guint g_scanner_key_hash (gconstpointer v);
static void g_scanner_get_token_ll (GScanner *scanner, 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, g_scanner_key_equal (gconstpointer v1,
gconstpointer v2) gconstpointer v2)
{ {

View File

@@ -69,6 +69,8 @@ typedef const void *gconstpointer;
typedef gint (*GCompareFunc) (gconstpointer a, typedef gint (*GCompareFunc) (gconstpointer a,
gconstpointer b); gconstpointer b);
typedef gboolean (*GEqualFunc) (gconstpointer a,
gconstpointer b);
typedef void (*GDestroyNotify) (gpointer data); typedef void (*GDestroyNotify) (gpointer data);
typedef void (*GFunc) (gpointer data, typedef void (*GFunc) (gpointer data,
gpointer user_data); gpointer user_data);

View File

@@ -917,14 +917,14 @@ g_direct_hash (gconstpointer v)
return GPOINTER_TO_UINT (v); return GPOINTER_TO_UINT (v);
} }
gint gboolean
g_direct_equal (gconstpointer v1, g_direct_equal (gconstpointer v1,
gconstpointer v2) gconstpointer v2)
{ {
return v1 == v2; return v1 == v2;
} }
gint gboolean
g_int_equal (gconstpointer v1, g_int_equal (gconstpointer v1,
gconstpointer v2) gconstpointer v2)
{ {

6
grel.c
View File

@@ -85,7 +85,7 @@ tuple_hash (gint fields)
return NULL; return NULL;
} }
static GCompareFunc static GEqualFunc
tuple_equal (gint fields) tuple_equal (gint fields)
{ {
switch (fields) switch (fields)
@@ -150,7 +150,7 @@ void
g_relation_index (GRelation *relation, g_relation_index (GRelation *relation,
gint field, gint field,
GHashFunc hash_func, GHashFunc hash_func,
GCompareFunc key_compare_func) GEqualFunc key_equal_func)
{ {
GRealRelation *rel = (GRealRelation *) relation; 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); 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 void

2
grel.h
View File

@@ -67,7 +67,7 @@ void g_relation_destroy (GRelation *relation);
void g_relation_index (GRelation *relation, void g_relation_index (GRelation *relation,
gint field, gint field,
GHashFunc hash_func, GHashFunc hash_func,
GCompareFunc key_compare_func); GEqualFunc key_equal_func);
void g_relation_insert (GRelation *relation, void g_relation_insert (GRelation *relation,
...); ...);
gint g_relation_delete (GRelation *relation, gint g_relation_delete (GRelation *relation,

View File

@@ -127,7 +127,7 @@ static inline
GScannerKey* g_scanner_lookup_internal (GScanner *scanner, GScannerKey* g_scanner_lookup_internal (GScanner *scanner,
guint scope_id, guint scope_id,
const gchar *symbol); const gchar *symbol);
static gint g_scanner_key_equal (gconstpointer v1, static gboolean g_scanner_key_equal (gconstpointer v1,
gconstpointer v2); gconstpointer v2);
static guint g_scanner_key_hash (gconstpointer v); static guint g_scanner_key_hash (gconstpointer v);
static void g_scanner_get_token_ll (GScanner *scanner, 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, g_scanner_key_equal (gconstpointer v1,
gconstpointer v2) gconstpointer v2)
{ {

View File

@@ -69,6 +69,8 @@ typedef const void *gconstpointer;
typedef gint (*GCompareFunc) (gconstpointer a, typedef gint (*GCompareFunc) (gconstpointer a,
gconstpointer b); gconstpointer b);
typedef gboolean (*GEqualFunc) (gconstpointer a,
gconstpointer b);
typedef void (*GDestroyNotify) (gpointer data); typedef void (*GDestroyNotify) (gpointer data);
typedef void (*GFunc) (gpointer data, typedef void (*GFunc) (gpointer data,
gpointer user_data); gpointer user_data);

View File

@@ -917,14 +917,14 @@ g_direct_hash (gconstpointer v)
return GPOINTER_TO_UINT (v); return GPOINTER_TO_UINT (v);
} }
gint gboolean
g_direct_equal (gconstpointer v1, g_direct_equal (gconstpointer v1,
gconstpointer v2) gconstpointer v2)
{ {
return v1 == v2; return v1 == v2;
} }
gint gboolean
g_int_equal (gconstpointer v1, g_int_equal (gconstpointer v1,
gconstpointer v2) gconstpointer v2)
{ {

View File

@@ -238,9 +238,9 @@ my_hash (gconstpointer key)
return (guint) *((const gint*) key); return (guint) *((const gint*) key);
} }
static gint static gboolean
my_hash_compare (gconstpointer a, my_hash_equal (gconstpointer a,
gconstpointer b) gconstpointer b)
{ {
return *((const gint*) a) == *((const gint*) b); return *((const gint*) a) == *((const gint*) b);
} }
@@ -617,7 +617,7 @@ main (int argc,
g_print ("checking hash tables..."); 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++) for (i = 0; i < 10000; i++)
{ {
array[i] = i; array[i] = i;

View File

@@ -84,9 +84,9 @@ my_hash (gconstpointer key)
return (guint) *((const gint*) key); return (guint) *((const gint*) key);
} }
static gint static gboolean
my_hash_compare (gconstpointer a, my_hash_equal (gconstpointer a,
gconstpointer b) gconstpointer b)
{ {
return *((const gint*) a) == *((const gint*) 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 (strcmp (a, b) == 0);
return rc;
} }
@@ -336,7 +334,7 @@ main (int argc,
GHashTable *hash_table; GHashTable *hash_table;
gint i; 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++) for (i = 0; i < 10000; i++)
{ {
array[i] = i; array[i] = i;

View File

@@ -238,9 +238,9 @@ my_hash (gconstpointer key)
return (guint) *((const gint*) key); return (guint) *((const gint*) key);
} }
static gint static gboolean
my_hash_compare (gconstpointer a, my_hash_equal (gconstpointer a,
gconstpointer b) gconstpointer b)
{ {
return *((const gint*) a) == *((const gint*) b); return *((const gint*) a) == *((const gint*) b);
} }
@@ -617,7 +617,7 @@ main (int argc,
g_print ("checking hash tables..."); 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++) for (i = 0; i < 10000; i++)
{ {
array[i] = i; array[i] = i;