diff options
Diffstat (limited to 'src/mesa/shader/hash_table.c')
-rw-r--r-- | src/mesa/shader/hash_table.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/mesa/shader/hash_table.c b/src/mesa/shader/hash_table.c index 933e300abdd..f7ef366c1a0 100644 --- a/src/mesa/shader/hash_table.c +++ b/src/mesa/shader/hash_table.c @@ -142,6 +142,23 @@ hash_table_insert(struct hash_table *ht, void *data, const void *key) insert_at_head(& ht->buckets[bucket], & node->link); } +void +hash_table_remove(struct hash_table *ht, const void *key) +{ + const unsigned hash_value = (*ht->hash)(key); + const unsigned bucket = hash_value % ht->num_buckets; + struct node *node; + + foreach(node, & ht->buckets[bucket]) { + struct hash_node *hn = (struct hash_node *) node; + + if ((*ht->compare)(hn->key, key) == 0) { + remove_from_list(node); + free(node); + return; + } + } +} unsigned hash_table_string_hash(const void *key) |