summaryrefslogtreecommitdiffstats
path: root/src/util/disk_cache.c
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2016-04-26 14:56:22 +1000
committerTimothy Arceri <[email protected]>2017-02-09 12:22:56 +1100
commit4026b45bbc4c2c067feeee181c54e2beaa1cc5e0 (patch)
treee0d1f8709eb1eb2fb6bfd0d6debf0e716ab0be61 /src/util/disk_cache.c
parenta3fd8bb8c58e35ef06928fe0c565480b0e8f6343 (diff)
util: add a disk_cache_remove() function
This will be used to remove cache items created with old versions of Mesa or other invalid cache items from the cache. V2: rename stub function (cache_* funtions were renamed disk_cache_*) in master. Reviewed-by: Anuj Phogat <[email protected]>
Diffstat (limited to 'src/util/disk_cache.c')
-rw-r--r--src/util/disk_cache.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
index 551ceebd3b8..7451b083398 100644
--- a/src/util/disk_cache.c
+++ b/src/util/disk_cache.c
@@ -538,6 +538,28 @@ evict_random_item(struct disk_cache *cache)
}
void
+disk_cache_remove(struct disk_cache *cache, cache_key key)
+{
+ struct stat sb;
+
+ char *filename = get_cache_file(cache, key);
+ if (filename == NULL) {
+ return;
+ }
+
+ if (stat(filename, &sb) == -1) {
+ ralloc_free(filename);
+ return;
+ }
+
+ unlink(filename);
+ ralloc_free(filename);
+
+ if (sb.st_size)
+ p_atomic_add(cache->size, - sb.st_size);
+}
+
+void
disk_cache_put(struct disk_cache *cache,
cache_key key,
const void *data,