summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliot Lee <sopwith@src.gnome.org>1998-04-07 22:33:20 +0000
committerElliot Lee <sopwith@src.gnome.org>1998-04-07 22:33:20 +0000
commit6788abaa48826759341f5524853ad24d61f32dcc (patch)
treec2deb8ef9fc70858a44456ca27396d0986a6f6c6
parent39a05c0b55f444eea0a943378c54546f8feea52a (diff)
downloadgtk+-6788abaa48826759341f5524853ad24d61f32dcc.tar.gz
added g_direct_hash and g_direct_compare functions, since I happen to use them in a *lot* of places
-rw-r--r--glib/glib.h6
-rw-r--r--glib/gutils.c11
2 files changed, 16 insertions, 1 deletions
diff --git a/glib/glib.h b/glib/glib.h
index 735874f5f7..4a8423d0ad 100644
--- a/glib/glib.h
+++ b/glib/glib.h
@@ -782,7 +782,11 @@ GArray* g_rarray_truncate (GArray *array,
gint g_str_equal (const gpointer v,
const gpointer v2);
guint g_str_hash (const gpointer v);
-
+/* These two "hash" functions actually just return the value and/or
+ comparison of the pointers themselves - useful for hashing
+ on an int value or something like that */
+gint g_direct_compare(gpointer a, gpointer b);
+guint g_direct_hash(gpointer key);
/* GScanner: Flexible lexical scanner for general purpose.
diff --git a/glib/gutils.c b/glib/gutils.c
index b15c4acf52..9f38714243 100644
--- a/glib/gutils.c
+++ b/glib/gutils.c
@@ -909,3 +909,14 @@ g_parse_debug_string (const gchar *string,
return result;
}
+guint
+g_direct_hash(gpointer key)
+{
+ return (guint)key;
+}
+
+gint
+g_direct_compare(gpointer a, gpointer b)
+{
+ return (gint)b - (gint)a;
+}