mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-26 03:30:22 +01:00
util: Add remove to util_cache
I need to be able to remove entries from util_cache caches. This change enables that functionality.
This commit is contained in:
parent
eb2e8167fa
commit
d00cbf46cd
2 changed files with 26 additions and 0 deletions
|
|
@ -215,3 +215,25 @@ util_cache_destroy(struct util_cache *cache)
|
|||
FREE(cache->entries);
|
||||
FREE(cache);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
util_cache_remove(struct util_cache *cache,
|
||||
const void *key)
|
||||
{
|
||||
struct util_cache_entry *entry;
|
||||
uint32_t hash;
|
||||
|
||||
assert(cache);
|
||||
if (!cache)
|
||||
return;
|
||||
|
||||
hash = cache->hash(key);
|
||||
|
||||
entry = util_cache_entry_get(cache, hash, key);
|
||||
if (!entry)
|
||||
return;
|
||||
|
||||
if (entry->state == FILLED)
|
||||
util_cache_entry_destroy(cache, entry);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,6 +79,10 @@ util_cache_clear(struct util_cache *cache);
|
|||
void
|
||||
util_cache_destroy(struct util_cache *cache);
|
||||
|
||||
void
|
||||
util_cache_remove(struct util_cache *cache,
|
||||
const void *key);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue