summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/cso_cache
diff options
context:
space:
mode:
authorZack Rusin <zack@tungstengraphics.com>2008-03-10 22:10:18 -0400
committerZack Rusin <zack@tungstengraphics.com>2008-03-10 22:12:32 -0400
commitbe9a2457388d99a2185f258aeb5ef5183ccfbbb2 (patch)
treeb510c2c4cb0ebc85787dd60b088d28a16fc3df93 /src/gallium/auxiliary/cso_cache
parentd9d2ca7a07469a7d5cdc183f2daa6cf9e30938fe (diff)
fix double deletion
plus, if the current hash is bigger than max size make sure we delete enough from it
Diffstat (limited to 'src/gallium/auxiliary/cso_cache')
-rw-r--r--src/gallium/auxiliary/cso_cache/cso_cache.c5
-rw-r--r--src/gallium/auxiliary/cso_cache/cso_hash.c7
2 files changed, 4 insertions, 8 deletions
diff --git a/src/gallium/auxiliary/cso_cache/cso_cache.c b/src/gallium/auxiliary/cso_cache/cso_cache.c
index b427b509f8..a2764b4265 100644
--- a/src/gallium/auxiliary/cso_cache/cso_cache.c
+++ b/src/gallium/auxiliary/cso_cache/cso_cache.c
@@ -207,8 +207,11 @@ static INLINE void sanitize_hash(struct cso_hash *hash, enum cso_cache_type type
{
/* if we're approach the maximum size, remove fourth of the entries
* otherwise every subsequent call will go through the same */
- int max_entries = (max_size > cso_hash_size(hash)) ? max_size : cso_hash_size(hash);
+ int hash_size = cso_hash_size(hash);
+ int max_entries = (max_size > hash_size) ? max_size : hash_size;
int to_remove = (max_size < max_entries) * max_entries/4;
+ if (hash_size > max_size)
+ to_remove += hash_size - max_size;
while (to_remove) {
/*remove elements until we're good */
/*fixme: currently we pick the nodes to remove at random*/
diff --git a/src/gallium/auxiliary/cso_cache/cso_hash.c b/src/gallium/auxiliary/cso_cache/cso_hash.c
index b3b4d667d2..5cad5d3be7 100644
--- a/src/gallium/auxiliary/cso_cache/cso_hash.c
+++ b/src/gallium/auxiliary/cso_cache/cso_hash.c
@@ -101,13 +101,6 @@ static void *cso_data_allocate_node(struct cso_hash_data *hash)
static void cso_data_free_node(struct cso_node *node)
{
- /* XXX still a leak here.
- * Need to cast value ptr to original cso type, then free the
- * driver-specific data hanging off of it. For example:
- struct cso_sampler *csamp = (struct cso_sampler *) node->value;
- FREE(csamp->data);
- */
- FREE(node->value);
FREE(node);
}