summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/util/hash_table.c10
-rw-r--r--src/util/hash_table.h3
-rw-r--r--src/util/set.c11
-rw-r--r--src/util/set.h3
4 files changed, 27 insertions, 0 deletions
diff --git a/src/util/hash_table.c b/src/util/hash_table.c
index 4f510612a8f..57a5f247edc 100644
--- a/src/util/hash_table.c
+++ b/src/util/hash_table.c
@@ -548,6 +548,16 @@ _mesa_key_pointer_equal(const void *a, const void *b)
}
/**
+ * Helper to create a hash table with pointer keys.
+ */
+struct hash_table *
+_mesa_pointer_hash_table_create(void *mem_ctx)
+{
+ return _mesa_hash_table_create(mem_ctx, _mesa_hash_pointer,
+ _mesa_key_pointer_equal);
+}
+
+/**
* Hash table wrapper which supports 64-bit keys.
*
* TODO: unify all hash table implementations.
diff --git a/src/util/hash_table.h b/src/util/hash_table.h
index 40acda1fd1e..e451bd7c21b 100644
--- a/src/util/hash_table.h
+++ b/src/util/hash_table.h
@@ -121,6 +121,9 @@ static inline uint32_t _mesa_hash_pointer(const void *pointer)
return (uint32_t) ((num >> 2) ^ (num >> 6) ^ (num >> 10) ^ (num >> 14));
}
+struct hash_table *
+_mesa_pointer_hash_table_create(void *mem_ctx);
+
enum {
_mesa_fnv32_1a_offset_bias = 2166136261u,
};
diff --git a/src/util/set.c b/src/util/set.c
index fe5b10f0fee..18f1262e3f5 100644
--- a/src/util/set.c
+++ b/src/util/set.c
@@ -36,6 +36,7 @@
#include <assert.h>
#include <string.h>
+#include "hash_table.h"
#include "macros.h"
#include "ralloc.h"
#include "set.h"
@@ -437,3 +438,13 @@ _mesa_set_random_entry(struct set *ht,
return NULL;
}
+
+/**
+ * Helper to create a set with pointer keys.
+ */
+struct set *
+_mesa_pointer_set_create(void *mem_ctx)
+{
+ return _mesa_set_create(mem_ctx, _mesa_hash_pointer,
+ _mesa_key_pointer_equal);
+}
diff --git a/src/util/set.h b/src/util/set.h
index 54719e4c8ab..307a2e46765 100644
--- a/src/util/set.h
+++ b/src/util/set.h
@@ -91,6 +91,9 @@ struct set_entry *
_mesa_set_random_entry(struct set *set,
int (*predicate)(struct set_entry *entry));
+struct set *
+_mesa_pointer_set_create(void *mem_ctx);
+
/**
* This foreach function is safe against deletion, but not against
* insertion (which may rehash the set, making entry a dangling