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:
Alex Corscadden 2011-01-06 10:59:13 -08:00 committed by José Fonseca
parent eb2e8167fa
commit d00cbf46cd
2 changed files with 26 additions and 0 deletions

View file

@ -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);
}

View file

@ -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
}