fixup! fscache: teach fscache to use mempool

Needed for the recent mem-pool changes.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin
2020-08-19 10:27:02 +02:00
parent 29be755d4f
commit edc387f0e6

View File

@@ -19,7 +19,7 @@ CRITICAL_SECTION fscache_cs;
struct fscache {
volatile long enabled;
struct hashmap map;
struct mem_pool *mem_pool;
struct mem_pool mem_pool;
unsigned int lstat_requests;
unsigned int opendir_requests;
unsigned int fscache_requests;
@@ -132,7 +132,7 @@ static struct fsentry *fsentry_alloc(struct fscache *cache, struct fsentry *list
{
/* overallocate fsentry and copy the name to the end */
struct fsentry *fse =
mem_pool_alloc(cache->mem_pool, sizeof(*fse) + len + 1);
mem_pool_alloc(&cache->mem_pool, sizeof(*fse) + len + 1);
/* init the rest of the structure */
fsentry_init(fse, list, name, len);
fse->next = NULL;
@@ -355,8 +355,7 @@ static void fscache_add(struct fscache *cache, struct fsentry *fse)
*/
static void fscache_clear(struct fscache *cache)
{
mem_pool_discard(cache->mem_pool, 0);
cache->mem_pool = NULL;
mem_pool_discard(&cache->mem_pool, 0);
mem_pool_init(&cache->mem_pool, 0);
hashmap_free(&cache->map);
hashmap_init(&cache->map, (hashmap_cmp_fn)fsentry_cmp, NULL, 0);
@@ -534,7 +533,7 @@ void fscache_disable(void)
"total requests/misses %u/%u\n",
cache->lstat_requests, cache->opendir_requests,
cache->fscache_requests, cache->fscache_misses);
mem_pool_discard(cache->mem_pool, 0);
mem_pool_discard(&cache->mem_pool, 0);
hashmap_free(&cache->map);
free(cache);
}
@@ -766,7 +765,7 @@ void fscache_merge(struct fscache *dest)
while ((e = hashmap_iter_next(&iter)))
hashmap_add(&dest->map, e);
mem_pool_combine(dest->mem_pool, cache->mem_pool);
mem_pool_combine(&dest->mem_pool, &cache->mem_pool);
dest->lstat_requests += cache->lstat_requests;
dest->opendir_requests += cache->opendir_requests;