aboutsummaryrefslogtreecommitdiffstats
path: root/src/util/set.c
Commit message (Collapse)AuthorAgeFilesLines
* util/set: helper to remove entry by keyCaio Marcelo de Oliveira Filho2018-07-121-0/+9
| | | | | | v2: Add unit test. (Eric Anholt) Reviewed-by: Eric Anholt <[email protected]>
* util/set: add a clone functionCaio Marcelo de Oliveira Filho2018-07-121-0/+23
| | | | | | v2: Add unit test. (Eric Anholt) Reviewed-by: Eric Anholt <[email protected]>
* util/set: add a set_clear functionScott D Phillips2018-05-041-0/+23
| | | | | | | Clear a set back to the state of having zero entries. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* util: Use set_foreach instead of rolling our ownThomas Helland2018-03-141-6/+2
| | | | | | This follows the same pattern as in the hash_table. Reviewed-by: Jason Ekstrand <jason.ekstrand at intel.com>
* util: make set's deleted_key_value declaration consistent with hash table oneVlad Golovkin2017-06-081-2/+2
| | | | | | | | | | | | | This also silences following clang warnings: no previous extern declaration for non-static variable 'deleted_key' [-Werror,-Wmissing-variable-declarations] const void *deleted_key = &deleted_key_value; ^ no previous extern declaration for non-static variable 'deleted_key_value' [-Werror,-Wmissing-variable-declarations] uint32_t deleted_key_value; ^ Reviewed-by: Nicolai Hähnle <[email protected]>
* util/set: don't compare against deleted entriesConnor Abbott2016-02-021-1/+2
| | | | | | | | | | | | | | | | | | When we delete entries in the hash set, we mark them "deleted" by setting their key to the deleted_key, which points to a dummy deleted_key_value. When searching for an entry, we normally skip over those, but set_add() had some code for searching for duplicate entries which forgot to skip over deleted entries. This led to a segfault inside the NIR vectorization pass, since its key comparison function interpreted the memory where deleted_key_value resides as a pointer and tried to dereference it. v2: - add better commit message (Timothy) - use entry_is_deleted (Timothy) Reviewed-by: Timothy Arceri <[email protected]> Signed-off-by: Connor Abbott <[email protected]>
* util/set: Do a full search when adding new itemsJason Ekstrand2015-02-071-6/+15
| | | | | | | | | | | | Previously, the set_insert function would bail early if it found a deleted slot that it could re-use. However, this is a problem if the key being inserted is already in the set but further down the list. If this happens, the element ends up getting inserted in the set twice. This commit makes it so that we walk over all of the possible entries for the given key and then, if we don't find the key, place it in the available free entry we found. Reviewed-by: Eric Anholt <[email protected]>
* mesa: Fix some signed-unsigned comparison warningsJan Vesely2015-01-211-1/+1
| | | | | | | | v2: s/unsigned int/unsigned/ in prog_optimize.c Signed-off-by: Jan Vesely <[email protected]> Reviewed-by: David Heidelberg <[email protected]> Reviewed-by: Jose Fonseca <[email protected]>
* util/hash_set: Rework the API to know about hashingJason Ekstrand2015-01-151-5/+42
| | | | | | | | | | | | | | | | | | | | | | | | Previously, the set API required the user to do all of the hashing of keys as it passed them in. Since the hashing function is intrinsically tied to the comparison function, it makes sense for the hash set to know about it. Also, it makes for a somewhat clumsy API as the user is constantly calling hashing functions many of which have long names. This is especially bad when the standard call looks something like _mesa_set_add(ht, _mesa_pointer_hash(key), key); In the above case, there is no reason why the hash set shouldn't do the hashing for you. We leave the option for you to do your own hashing if it's more efficient, but it's no longer needed. Also, if you do do your own hashing, the hash set will assert that your hash matches what it expects out of the hashing function. This should make it harder to mess up your hashing. This is analygous to 94303a0750 where we did this for hash_table Signed-off-by: Jason Ekstrand <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* util: Move main/set to util/hash_setJason Ekstrand2015-01-151-0/+345
Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Eric Anholt <[email protected]>