* MT safe
*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include "glib.h"
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)
}
}
-void
-g_hash_table_remove (GHashTable *hash_table,
- gconstpointer key)
+gboolean
+g_hash_table_remove (GHashTable *hash_table,
+ gconstpointer key)
{
GHashNode **node, *dest;
- g_return_if_fail (hash_table != NULL);
+ g_return_val_if_fail (hash_table != NULL, FALSE);
node = g_hash_table_lookup_node (hash_table, key);
-
if (*node)
{
dest = *node;
hash_table->nnodes--;
g_hash_table_resize (hash_table);
+
+ return TRUE;
}
+
+ return FALSE;
}
gboolean