X-Git-Url: https://git.libre-soc.org/?p=mesa.git;a=blobdiff_plain;f=src%2Fgallium%2Fauxiliary%2Futil%2Fu_cache.c;h=15f4a8831f21fad0ce0e647a698077bad4980203;hp=41cd38171fad21f4423f112af9d8531b56cc1c54;hb=ccd13da0fc1f1813b55fc0d2181a6cb0d3b42b0d;hpb=ea4bf267e4b023b08043f91ac44592fed1736e7f diff --git a/src/gallium/auxiliary/util/u_cache.c b/src/gallium/auxiliary/util/u_cache.c index 41cd38171fa..15f4a8831f2 100644 --- a/src/gallium/auxiliary/util/u_cache.c +++ b/src/gallium/auxiliary/util/u_cache.c @@ -137,6 +137,8 @@ util_cache_set(struct util_cache *cache, struct util_cache_entry *entry; assert(cache); + if (!cache) + return; entry = util_cache_entry_get(cache, key); util_cache_entry_destroy(cache, entry); @@ -158,6 +160,8 @@ util_cache_get(struct util_cache *cache, struct util_cache_entry *entry; assert(cache); + if (!cache) + return NULL; entry = util_cache_entry_get(cache, key); if(!entry->key && !entry->value) @@ -176,7 +180,9 @@ util_cache_clear(struct util_cache *cache) uint32_t i; assert(cache); - + if (!cache) + return; + for(i = 0; i < cache->size; ++i) util_cache_entry_destroy(cache, &cache->entries[i]); } @@ -186,6 +192,8 @@ void util_cache_destroy(struct util_cache *cache) { assert(cache); + if (!cache) + return; #ifdef DEBUG if(cache->count >= 20*cache->size) { @@ -194,7 +202,7 @@ util_cache_destroy(struct util_cache *cache) double stddev = sqrt(mean); unsigned i; for(i = 0; i < cache->size; ++i) { - double z = fabs(cache->count - mean)/stddev; + double z = fabs(cache->entries[i].count - mean)/stddev; /* This assert should not fail 99.9999998027% of the times, unless * the hash function is a poor one */ assert(z <= 6.0);