+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.
+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.
+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.
+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.
+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.
+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.
+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.
+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.
GCacheDestroyFunc key_destroy_func,
GHashFunc hash_key_func,
GHashFunc hash_value_func,
- GCompareFunc key_compare_func)
+ GEqualFunc key_equal_func)
{
GRealCache *cache;
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;
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);
gint nnodes;
GHashNode **nodes;
GHashFunc hash_func;
- GCompareFunc key_compare_func;
+ GEqualFunc key_equal_func;
};
GHashTable*
g_hash_table_new (GHashFunc hash_func,
- GCompareFunc key_compare_func)
+ GEqualFunc key_equal_func)
{
GHashTable *hash_table;
guint i;
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++)
/* 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)
/* 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,
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;
* 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
GCacheDestroyFunc key_destroy_func,
GHashFunc hash_key_func,
GHashFunc hash_value_func,
- GCompareFunc key_compare_func)
+ GEqualFunc key_equal_func)
{
GRealCache *cache;
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;
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);
gint nnodes;
GHashNode **nodes;
GHashFunc hash_func;
- GCompareFunc key_compare_func;
+ GEqualFunc key_equal_func;
};
GHashTable*
g_hash_table_new (GHashFunc hash_func,
- GCompareFunc key_compare_func)
+ GEqualFunc key_equal_func)
{
GHashTable *hash_table;
guint i;
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++)
/* 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)
/* 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,
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;
* 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
return NULL;
}
-static GCompareFunc
+static GEqualFunc
tuple_equal (gint fields)
{
switch (fields)
g_relation_index (GRelation *relation,
gint field,
GHashFunc hash_func,
- GCompareFunc key_compare_func)
+ GEqualFunc key_equal_func)
{
GRealRelation *rel = (GRealRelation *) 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
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,
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,
}
}
-static gint
+static gboolean
g_scanner_key_equal (gconstpointer v1,
gconstpointer v2)
{
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);
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)
{
return NULL;
}
-static GCompareFunc
+static GEqualFunc
tuple_equal (gint fields)
{
switch (fields)
g_relation_index (GRelation *relation,
gint field,
GHashFunc hash_func,
- GCompareFunc key_compare_func)
+ GEqualFunc key_equal_func)
{
GRealRelation *rel = (GRealRelation *) 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
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,
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,
}
}
-static gint
+static gboolean
g_scanner_key_equal (gconstpointer v1,
gconstpointer v2)
{
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);
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)
{
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);
}
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;
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);
}
}
-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);
}
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;
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);
}
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;