Cygwin support contributed by Stefan Ondrejicka <ondrej@idata.sk>.
[platform/upstream/glib.git] / ghash.c
diff --git a/ghash.c b/ghash.c
index 8b4b048..8ac9ff2 100644 (file)
--- a/ghash.c
+++ b/ghash.c
@@ -2,23 +2,23 @@
  * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
+ * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the GNU
- * Library General Public License for more details.
+ * Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU Library General Public
+ * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
  */
 
 /*
- * Modified by the GLib Team and others 1997-1999.  See the AUTHORS
+ * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
  * file for a list of people on the GLib Team.  See the ChangeLog
  * files for a list of changes.  These files are distributed with
  * GLib at ftp://ftp.gtk.org/pub/gtk/. 
  * 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