diff options
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/set.c | 14 | ||||
-rw-r--r-- | src/util/set.h | 2 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/util/set.c b/src/util/set.c index 2fd54a71a6f..c2b97bdea08 100644 --- a/src/util/set.c +++ b/src/util/set.c @@ -280,6 +280,20 @@ set_rehash(struct set *ht, unsigned new_size_index) ralloc_free(old_ht.table); } +void +_mesa_set_resize(struct set *set, uint32_t entries) +{ + /* You can't shrink a set below its number of entries */ + if (set->entries > entries) + entries = set->entries; + + unsigned size_index = 0; + while (hash_sizes[size_index].max_entries < entries) + size_index++; + + set_rehash(set, size_index); +} + /** * Inserts the key with the given hash into the table. * diff --git a/src/util/set.h b/src/util/set.h index 7d277c59f8b..5742c311a77 100644 --- a/src/util/set.h +++ b/src/util/set.h @@ -65,6 +65,8 @@ void _mesa_set_destroy(struct set *set, void (*delete_function)(struct set_entry *entry)); void +_mesa_set_resize(struct set *set, uint32_t entries); +void _mesa_set_clear(struct set *set, void (*delete_function)(struct set_entry *entry)); |