util/disk_cache: use unambiguous naming
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
This commit is contained in:
@@ -53,7 +53,7 @@
|
||||
/* The number of keys that can be stored in the index. */
|
||||
#define CACHE_INDEX_MAX_KEYS (1 << CACHE_INDEX_KEY_BITS)
|
||||
|
||||
struct program_cache {
|
||||
struct disk_cache {
|
||||
/* The path to the cache directory. */
|
||||
char *path;
|
||||
|
||||
@@ -131,11 +131,11 @@ concatenate_and_mkdir(void *ctx, char *path, char *name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct program_cache *
|
||||
cache_create(void)
|
||||
struct disk_cache *
|
||||
disk_cache_create(void)
|
||||
{
|
||||
void *local;
|
||||
struct program_cache *cache = NULL;
|
||||
struct disk_cache *cache = NULL;
|
||||
char *path, *max_size_str;
|
||||
uint64_t max_size;
|
||||
int fd = -1;
|
||||
@@ -210,7 +210,7 @@ cache_create(void)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
cache = ralloc(NULL, struct program_cache);
|
||||
cache = ralloc(NULL, struct disk_cache);
|
||||
if (cache == NULL)
|
||||
goto fail;
|
||||
|
||||
@@ -313,7 +313,7 @@ cache_create(void)
|
||||
}
|
||||
|
||||
void
|
||||
cache_destroy(struct program_cache *cache)
|
||||
disk_cache_destroy(struct disk_cache *cache)
|
||||
{
|
||||
munmap(cache->index_mmap, cache->index_mmap_size);
|
||||
|
||||
@@ -326,7 +326,7 @@ cache_destroy(struct program_cache *cache)
|
||||
* Returns NULL if out of memory.
|
||||
*/
|
||||
static char *
|
||||
get_cache_file(struct program_cache *cache, cache_key key)
|
||||
get_cache_file(struct disk_cache *cache, cache_key key)
|
||||
{
|
||||
char buf[41];
|
||||
|
||||
@@ -342,7 +342,7 @@ get_cache_file(struct program_cache *cache, cache_key key)
|
||||
* _get_cache_file above.
|
||||
*/
|
||||
static void
|
||||
make_cache_file_directory(struct program_cache *cache, cache_key key)
|
||||
make_cache_file_directory(struct disk_cache *cache, cache_key key)
|
||||
{
|
||||
char *dir;
|
||||
char buf[41];
|
||||
@@ -484,7 +484,7 @@ is_two_character_sub_directory(struct dirent *entry)
|
||||
}
|
||||
|
||||
static void
|
||||
evict_random_item(struct program_cache *cache)
|
||||
evict_random_item(struct disk_cache *cache)
|
||||
{
|
||||
const char hex[] = "0123456789abcde";
|
||||
char *dir_path;
|
||||
@@ -531,7 +531,7 @@ evict_random_item(struct program_cache *cache)
|
||||
}
|
||||
|
||||
void
|
||||
cache_put(struct program_cache *cache,
|
||||
disk_cache_put(struct disk_cache *cache,
|
||||
cache_key key,
|
||||
const void *data,
|
||||
size_t size)
|
||||
@@ -628,7 +628,7 @@ cache_put(struct program_cache *cache,
|
||||
}
|
||||
|
||||
void *
|
||||
cache_get(struct program_cache *cache, cache_key key, size_t *size)
|
||||
disk_cache_get(struct disk_cache *cache, cache_key key, size_t *size)
|
||||
{
|
||||
int fd = -1, ret, len;
|
||||
struct stat sb;
|
||||
@@ -679,7 +679,7 @@ cache_get(struct program_cache *cache, cache_key key, size_t *size)
|
||||
}
|
||||
|
||||
void
|
||||
cache_put_key(struct program_cache *cache, cache_key key)
|
||||
disk_cache_put_key(struct disk_cache *cache, cache_key key)
|
||||
{
|
||||
uint32_t *key_chunk = (uint32_t *) key;
|
||||
int i = *key_chunk & CACHE_INDEX_KEY_MASK;
|
||||
@@ -691,14 +691,14 @@ cache_put_key(struct program_cache *cache, cache_key key)
|
||||
}
|
||||
|
||||
/* This function lets us test whether a given key was previously
|
||||
* stored in the cache with cache_put_key(). The implement is
|
||||
* stored in the cache with disk_cache_put_key(). The implement is
|
||||
* efficient by not using syscalls or hitting the disk. It's not
|
||||
* race-free, but the races are benign. If we race with someone else
|
||||
* calling cache_put_key, then that's just an extra cache miss and an
|
||||
* calling disk_cache_put_key, then that's just an extra cache miss and an
|
||||
* extra recompile.
|
||||
*/
|
||||
bool
|
||||
cache_has_key(struct program_cache *cache, cache_key key)
|
||||
disk_cache_has_key(struct disk_cache *cache, cache_key key)
|
||||
{
|
||||
uint32_t *key_chunk = (uint32_t *) key;
|
||||
int i = *key_chunk & CACHE_INDEX_KEY_MASK;
|
||||
|
Reference in New Issue
Block a user