aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/program/hash_table.h
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-10-19 10:44:43 +0200
committermarha <marha@users.sourceforge.net>2011-10-19 10:44:43 +0200
commit9f986778bd4393c5a9108426969d45aa7f10f334 (patch)
tree27d7bd08dac54a54a923e76dccf2b8e388be2a03 /mesalib/src/mesa/program/hash_table.h
parentafbd3947071a33f59dda122f1ac396442a02c128 (diff)
downloadvcxsrv-9f986778bd4393c5a9108426969d45aa7f10f334.tar.gz
vcxsrv-9f986778bd4393c5a9108426969d45aa7f10f334.tar.bz2
vcxsrv-9f986778bd4393c5a9108426969d45aa7f10f334.zip
libX11 libXext libXft mesa libxcb mkfontscale pixman xserver
xkeyboard-config git update 19 oct 2011
Diffstat (limited to 'mesalib/src/mesa/program/hash_table.h')
-rw-r--r--mesalib/src/mesa/program/hash_table.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/mesalib/src/mesa/program/hash_table.h b/mesalib/src/mesa/program/hash_table.h
index bfe221b24..941d28a4c 100644
--- a/mesalib/src/mesa/program/hash_table.h
+++ b/mesalib/src/mesa/program/hash_table.h
@@ -32,6 +32,7 @@
#define HASH_TABLE_H
#include <string.h>
+#include <stdlib.h>
#include <stdint.h>
#include <limits.h>
#include <assert.h>
@@ -100,6 +101,10 @@ extern void *hash_table_find(struct hash_table *ht, const void *key);
* calls to \c hash_table_find and \c hash_table_remove will return or remove,
* repsectively, the most recently added instance of \c key.
*
+ * \warning
+ * The value passed by \c key is kept in the hash table and is used by later
+ * calls to \c hash_table_find.
+ *
* \sa hash_table_replace
*/
extern void hash_table_insert(struct hash_table *ht, void *data,
@@ -204,6 +209,7 @@ public:
~string_to_uint_map()
{
+ hash_table_call_foreach(this->ht, delete_key, NULL);
hash_table_dtor(this->ht);
}
@@ -243,10 +249,20 @@ public:
* because UINT_MAX+1 = 0.
*/
assert(value != UINT_MAX);
- hash_table_replace(ht, (void *) (intptr_t) (value + 1), key);
+ hash_table_replace(this->ht,
+ (void *) (intptr_t) (value + 1),
+ strdup(key));
}
private:
+ static void delete_key(const void *key, void *data, void *closure)
+ {
+ (void) data;
+ (void) closure;
+
+ free((char *)key);
+ }
+
struct hash_table *ht;
};