mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-02-13 17:50:31 +01:00
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 <anuj.phogat@gmail.com>
This commit is contained in:
parent
a3fd8bb8c5
commit
4026b45bbc
2 changed files with 34 additions and 0 deletions
|
|
@ -537,6 +537,28 @@ evict_random_item(struct disk_cache *cache)
|
|||
p_atomic_add(cache->size, - size);
|
||||
}
|
||||
|
||||
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,
|
||||
|
|
|
|||
|
|
@ -77,6 +77,12 @@ disk_cache_create(void);
|
|||
void
|
||||
disk_cache_destroy(struct disk_cache *cache);
|
||||
|
||||
/**
|
||||
* Remove the item in the cache under the name \key.
|
||||
*/
|
||||
void
|
||||
disk_cache_remove(struct disk_cache *cache, cache_key key);
|
||||
|
||||
/**
|
||||
* Store an item in the cache under the name \key.
|
||||
*
|
||||
|
|
@ -151,6 +157,12 @@ disk_cache_put(struct disk_cache *cache, cache_key key,
|
|||
return;
|
||||
}
|
||||
|
||||
static inline void
|
||||
disk_cache_remove(struct program_cache *cache, cache_key key)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static inline uint8_t *
|
||||
disk_cache_get(struct disk_cache *cache, cache_key key, size_t *size)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue