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 15f4a88..e88f36d 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 8a612c6..be3631b 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
 }