util: Add remove to util_cache
authorAlex Corscadden <alexc@vmware.com>
Thu, 6 Jan 2011 18:59:13 +0000 (10:59 -0800)
committerJosé Fonseca <jfonseca@vmware.com>
Wed, 9 Mar 2011 11:16:49 +0000 (11:16 +0000)
I need to be able to remove entries from util_cache caches.  This change
enables that functionality.

src/gallium/auxiliary/util/u_cache.c
src/gallium/auxiliary/util/u_cache.h

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);
+}
index 8a612c6585f36841a90961629981330bc6e34b36..be3631b72541c042fcc43fab57ccf43718b16a2d 100644 (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
 }