summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2016-08-09 00:02:44 -0700
committerEric Anholt <[email protected]>2016-08-10 12:27:22 -0700
commit91945f9e91e46aef79700015da032e16c355c96c (patch)
tree3f65b81165df633da570ccf1c27b898d00dcc262 /src
parent60f1b436b96f39f05af28348f997b089558574e6 (diff)
prog_hash_table: Convert compare funcs to match util/hash_table.h.
I'm going to replace this hash table with util/hash_table.h, and the first step is to compare things the same way. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/mesa/program/hash_table.h9
-rw-r--r--src/mesa/program/prog_hash_table.c9
2 files changed, 11 insertions, 7 deletions
diff --git a/src/mesa/program/hash_table.h b/src/mesa/program/hash_table.h
index d0a2abffa34..aba5282fe9e 100644
--- a/src/mesa/program/hash_table.h
+++ b/src/mesa/program/hash_table.h
@@ -47,7 +47,7 @@ extern "C" {
struct hash_table;
typedef unsigned (*hash_func_t)(const void *key);
-typedef int (*hash_compare_func_t)(const void *key1, const void *key2);
+typedef bool (*hash_compare_func_t)(const void *key1, const void *key2);
/**
* Hash table constructor
@@ -151,12 +151,11 @@ extern unsigned hash_table_string_hash(const void *key);
/**
* Compare two strings used as keys
*
- * This is just a macro wrapper around \c strcmp.
+ * This is just a wrapper around \c strcmp.
*
* \sa hash_table_string_hash
*/
-#define hash_table_string_compare ((hash_compare_func_t) strcmp)
-
+bool hash_table_string_compare(const void *a, const void *b);
/**
* Compute hash value of a pointer
@@ -178,7 +177,7 @@ hash_table_pointer_hash(const void *key);
*
* \sa hash_table_pointer_hash
*/
-int
+bool
hash_table_pointer_compare(const void *key1, const void *key2);
void
diff --git a/src/mesa/program/prog_hash_table.c b/src/mesa/program/prog_hash_table.c
index 5592b6fb814..f8a7107eb5b 100644
--- a/src/mesa/program/prog_hash_table.c
+++ b/src/mesa/program/prog_hash_table.c
@@ -228,6 +228,11 @@ hash_table_string_hash(const void *key)
return hash;
}
+bool hash_table_string_compare(const void *a, const void *b)
+{
+ return strcmp(a, b) == 0;
+}
+
unsigned
hash_table_pointer_hash(const void *key)
@@ -236,8 +241,8 @@ hash_table_pointer_hash(const void *key)
}
-int
+bool
hash_table_pointer_compare(const void *key1, const void *key2)
{
- return key1 == key2 ? 0 : 1;
+ return key1 == key2;
}