Mesa (gallium-0.2): add cso_hash_contains() function

Alan Hourihane alanh at kemper.freedesktop.org
Wed Sep 24 19:44:05 UTC 2008


Module: Mesa
Branch: gallium-0.2
Commit: 4fe186f8dc4fc7eeab3b1069c886458cfc2e517c
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=4fe186f8dc4fc7eeab3b1069c886458cfc2e517c

Author: Alan Hourihane <alanh at tungstengraphics.com>
Date:   Wed Sep 24 20:42:57 2008 +0100

add cso_hash_contains() function

---

 src/gallium/auxiliary/cso_cache/cso_hash.c |    6 ++++++
 src/gallium/auxiliary/cso_cache/cso_hash.h |    6 ++++++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/src/gallium/auxiliary/cso_cache/cso_hash.c b/src/gallium/auxiliary/cso_cache/cso_hash.c
index 7f0044c..4e7664f 100644
--- a/src/gallium/auxiliary/cso_cache/cso_hash.c
+++ b/src/gallium/auxiliary/cso_cache/cso_hash.c
@@ -431,3 +431,9 @@ struct cso_hash_iter cso_hash_erase(struct cso_hash *hash, struct cso_hash_iter
    --hash->data.d->size;
    return ret;
 }
+
+boolean cso_hash_contains(struct cso_hash *hash, unsigned key)
+{
+   struct cso_node **node = cso_hash_find_node(hash, key);
+   return (*node != hash->data.e);
+}
diff --git a/src/gallium/auxiliary/cso_cache/cso_hash.h b/src/gallium/auxiliary/cso_cache/cso_hash.h
index 85f3e27..5891c32 100644
--- a/src/gallium/auxiliary/cso_cache/cso_hash.h
+++ b/src/gallium/auxiliary/cso_cache/cso_hash.h
@@ -44,6 +44,7 @@
 #ifndef CSO_HASH_H
 #define CSO_HASH_H
 
+#include "pipe/p_compiler.h"
 
 #ifdef	__cplusplus
 extern "C" {
@@ -95,6 +96,11 @@ struct cso_hash_iter cso_hash_first_node(struct cso_hash *hash);
  */
 struct cso_hash_iter cso_hash_find(struct cso_hash *hash, unsigned key);
 
+/**
+ * Returns true if a value with the given key exists in the hash
+ */
+boolean   cso_hash_contains(struct cso_hash *hash, unsigned key);
+
 
 int       cso_hash_iter_is_null(struct cso_hash_iter iter);
 unsigned  cso_hash_iter_key(struct cso_hash_iter iter);




More information about the mesa-commit mailing list