Mesa (master): util: Add remove to util_cache

Jose Fonseca jrfonseca at kemper.freedesktop.org
Wed Mar 9 11:58:41 UTC 2011


Module: Mesa
Branch: master
Commit: d00cbf46cde0edee6d8f2c08e14458ef92ff0fbe
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=d00cbf46cde0edee6d8f2c08e14458ef92ff0fbe

Author: Alex Corscadden <alexc at vmware.com>
Date:   Thu Jan  6 10:59:13 2011 -0800

util: Add remove to util_cache

I need to be able to remove entries from util_cache caches.  This change
enables that functionality.

---

 src/gallium/auxiliary/util/u_cache.c |   22 ++++++++++++++++++++++
 src/gallium/auxiliary/util/u_cache.h |    4 ++++
 2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_cache.c b/src/gallium/auxiliary/util/u_cache.c
index 15f4a88..e88f36d 100644
--- a/src/gallium/auxiliary/util/u_cache.c
+++ b/src/gallium/auxiliary/util/u_cache.c
@@ -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);
+}
diff --git a/src/gallium/auxiliary/util/u_cache.h b/src/gallium/auxiliary/util/u_cache.h
index 8a612c6..be3631b 100644
--- a/src/gallium/auxiliary/util/u_cache.h
+++ b/src/gallium/auxiliary/util/u_cache.h
@@ -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
 }




More information about the mesa-commit mailing list