Cygwin support contributed by Stefan Ondrejicka <ondrej@idata.sk>.
[platform/upstream/glib.git] / ghash.c
diff --git a/ghash.c b/ghash.c
index a664e87..8ac9ff2 100644 (file)
--- a/ghash.c
+++ b/ghash.c
  * MT safe
  */
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "glib.h"
 
 
@@ -50,7 +54,7 @@ struct _GHashTable
   gint nnodes;
   GHashNode **nodes;
   GHashFunc hash_func;
-  GCompareFunc key_compare_func;
+  GEqualFunc key_equal_func;
 };
 
 
@@ -71,7 +75,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 +84,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 +118,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)
@@ -169,16 +173,15 @@ g_hash_table_insert (GHashTable *hash_table,
     }
 }
 
-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;
@@ -187,7 +190,11 @@ g_hash_table_remove (GHashTable         *hash_table,
       hash_table->nnodes--;
   
       g_hash_table_resize (hash_table);
+
+      return TRUE;
     }
+
+  return FALSE;
 }
 
 gboolean