util: Add remove to util_cache
[mesa.git] / src / gallium / auxiliary / util / u_cache.c
index 15f4a8831f21fad0ce0e647a698077bad4980203..e88f36dea75d8b14d5b4427b7798fb1d249a5967 100644 (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);
+}