diff options
author | marha <marha@users.sourceforge.net> | 2012-06-15 08:55:18 +0200 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2012-06-15 08:55:18 +0200 |
commit | d6f64084b9bc07d0bdd527f9354f2d1d962ed16d (patch) | |
tree | 81b2652d421992fd63143a04885e332e83e18d07 /mesalib/src/mesa/program | |
parent | 669b562a737c9418c53bfae69c0dbf1aabe318b4 (diff) | |
parent | 7a2af605c2c2b0d2e9bbb0b161eba8842acefbcb (diff) | |
download | vcxsrv-d6f64084b9bc07d0bdd527f9354f2d1d962ed16d.tar.gz vcxsrv-d6f64084b9bc07d0bdd527f9354f2d1d962ed16d.tar.bz2 vcxsrv-d6f64084b9bc07d0bdd527f9354f2d1d962ed16d.zip |
Merge remote-tracking branch 'origin/released'
Conflicts:
fontconfig/src/fcint.h
fontconfig/src/fcstat.c
mesalib/src/mapi/glapi/gen/GL3x.xml
xorg-server/glx/glxext.h
Diffstat (limited to 'mesalib/src/mesa/program')
-rw-r--r-- | mesalib/src/mesa/program/hash_table.c | 5 | ||||
-rw-r--r-- | mesalib/src/mesa/program/hash_table.h | 17 |
2 files changed, 16 insertions, 6 deletions
diff --git a/mesalib/src/mesa/program/hash_table.c b/mesalib/src/mesa/program/hash_table.c index dc8563a33..7dabadc50 100644 --- a/mesalib/src/mesa/program/hash_table.c +++ b/mesalib/src/mesa/program/hash_table.c @@ -149,7 +149,7 @@ hash_table_insert(struct hash_table *ht, void *data, const void *key) insert_at_head(& ht->buckets[bucket], & node->link); } -void +bool hash_table_replace(struct hash_table *ht, void *data, const void *key) { const unsigned hash_value = (*ht->hash)(key); @@ -162,7 +162,7 @@ hash_table_replace(struct hash_table *ht, void *data, const void *key) if ((*ht->compare)(hn->key, key) == 0) { hn->data = data; - return; + return true; } } @@ -172,6 +172,7 @@ hash_table_replace(struct hash_table *ht, void *data, const void *key) hn->key = key; insert_at_head(& ht->buckets[bucket], & hn->link); + return false; } void diff --git a/mesalib/src/mesa/program/hash_table.h b/mesalib/src/mesa/program/hash_table.h index e1c234ea4..b814497a6 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 <stdbool.h> #include <stdlib.h> #include <stdint.h> #include <limits.h> @@ -115,6 +116,10 @@ extern void hash_table_insert(struct hash_table *ht, void *data, /** * Add an element to a hash table with replacement * + * \return + * 1 if it did replace the the value (in which case the old key is kept), 0 if + * it did not replace the value (in which case the new key is kept). + * * \warning * If \c key is already in the hash table, \c data will \b replace the most * recently inserted \c data (see the warning in \c hash_table_insert) for @@ -122,7 +127,7 @@ extern void hash_table_insert(struct hash_table *ht, void *data, * * \sa hash_table_insert */ -extern void hash_table_replace(struct hash_table *ht, void *data, +extern bool hash_table_replace(struct hash_table *ht, void *data, const void *key); /** @@ -220,6 +225,7 @@ public: */ void clear() { + hash_table_call_foreach(this->ht, delete_key, NULL); hash_table_clear(this->ht); } @@ -259,9 +265,12 @@ public: * because UINT_MAX+1 = 0. */ assert(value != UINT_MAX); - hash_table_replace(this->ht, - (void *) (intptr_t) (value + 1), - strdup(key)); + char *dup_key = strdup(key); + bool result = hash_table_replace(this->ht, + (void *) (intptr_t) (value + 1), + dup_key); + if (result) + free(dup_key); } private: |