Lines Matching refs:cache

496     cache_t* cache = (cache_t*)calloc(1, sizeof(cache_t));  in start_cache_collection()  local
497 return cache; in start_cache_collection()
502 static void* _cache_malloc(cache_t* cache, size_t len) in _cache_malloc() argument
515 if (cache->memBlocks == NULL) { in _cache_malloc()
517 cache->memBlocks = res; in _cache_malloc()
519 *(void**)res = *(void**)cache->memBlocks; in _cache_malloc()
520 *(void**)cache->memBlocks = res; in _cache_malloc()
524 int8_t* res = cache->curMemBlockAvail; in _cache_malloc()
526 if (cache->memBlocks == NULL || nextPos > cache->curMemBlockEnd) { in _cache_malloc()
532 *(void**)newBlock = cache->memBlocks; in _cache_malloc()
533 cache->memBlocks = newBlock; in _cache_malloc()
534 res = cache->curMemBlockAvail = newBlock + sizeof(void*); in _cache_malloc()
535 cache->curMemBlockEnd = newBlock + CACHE_BLOCK_SIZE; in _cache_malloc()
539 res, len, cache->memBlocks, nextPos)); in _cache_malloc()
540 cache->curMemBlockAvail = nextPos; in _cache_malloc()
544 static void* _cache_realloc(cache_t* cache, void* cur, size_t origLen, size_t len) in _cache_realloc() argument
547 void* alloc = _cache_malloc(cache, len); in _cache_realloc()
554 static void _inc_num_cache_collected(cache_t* cache) in _inc_num_cache_collected() argument
556 cache->numCollected++; in _inc_num_cache_collected()
557 if ((cache->numCollected%20000) == 0) { in _inc_num_cache_collected()
559 cache->numDirs, cache->numFiles); in _inc_num_cache_collected()
563 static cache_dir_t* _add_cache_dir_t(cache_t* cache, cache_dir_t* parent, const char *name) in _add_cache_dir_t() argument
566 cache_dir_t* dir = (cache_dir_t*)_cache_malloc(cache, sizeof(cache_dir_t)+nameLen+1); in _add_cache_dir_t()
573 if (cache->numDirs >= cache->availDirs) { in _add_cache_dir_t()
574 size_t newAvail = cache->availDirs < 1000 ? 1000 : cache->availDirs*2; in _add_cache_dir_t()
575 cache_dir_t** newDirs = (cache_dir_t**)_cache_realloc(cache, cache->dirs, in _add_cache_dir_t()
576 cache->availDirs*sizeof(cache_dir_t*), newAvail*sizeof(cache_dir_t*)); in _add_cache_dir_t()
581 cache->availDirs = newAvail; in _add_cache_dir_t()
582 cache->dirs = newDirs; in _add_cache_dir_t()
584 cache->dirs[cache->numDirs] = dir; in _add_cache_dir_t()
585 cache->numDirs++; in _add_cache_dir_t()
589 _inc_num_cache_collected(cache); in _add_cache_dir_t()
596 static cache_file_t* _add_cache_file_t(cache_t* cache, cache_dir_t* dir, time_t modTime, in _add_cache_file_t() argument
600 cache_file_t* file = (cache_file_t*)_cache_malloc(cache, sizeof(cache_file_t)+nameLen+1); in _add_cache_file_t()
605 if (cache->numFiles >= cache->availFiles) { in _add_cache_file_t()
606 size_t newAvail = cache->availFiles < 1000 ? 1000 : cache->availFiles*2; in _add_cache_file_t()
607 cache_file_t** newFiles = (cache_file_t**)_cache_realloc(cache, cache->files, in _add_cache_file_t()
608 cache->availFiles*sizeof(cache_file_t*), newAvail*sizeof(cache_file_t*)); in _add_cache_file_t()
613 cache->availFiles = newAvail; in _add_cache_file_t()
614 cache->files = newFiles; in _add_cache_file_t()
617 cache->numFiles, cache->files)); in _add_cache_file_t()
618 cache->files[cache->numFiles] = file; in _add_cache_file_t()
619 cache->numFiles++; in _add_cache_file_t()
621 _inc_num_cache_collected(cache); in _add_cache_file_t()
628 static int _add_cache_files(cache_t *cache, cache_dir_t *parentDir, const char *dirName, in _add_cache_files() argument
644 cacheDir = _add_cache_dir_t(cache, parentDir, dirName); in _add_cache_files()
671 cacheDir = _add_cache_dir_t(cache, parentDir, dirName); in _add_cache_files()
680 _add_cache_files(cache, cacheDir, name, subdir, pathBase, in _add_cache_files()
700 cacheDir = _add_cache_dir_t(cache, parentDir, dirName); in _add_cache_files()
715 _add_cache_file_t(cache, cacheDir, s.st_mtime, name); in _add_cache_files()
741 void add_cache_files(cache_t* cache, const char *basepath, const char *cachedir) in add_cache_files() argument
782 _add_cache_files(cache, NULL, dirname, subdir, dirname, dirname+dirnameLen, in add_cache_files()
847 void clear_cache_files(const std::string& data_path, cache_t* cache, int64_t free_size) in clear_cache_files() argument
854 cache->numDirs, cache->numFiles); in clear_cache_files()
857 qsort(cache->files, cache->numFiles, sizeof(cache_file_t*), in clear_cache_files()
861 for (i=cache->numDirs; i>0; i--) { in clear_cache_files()
862 cache_dir_t* dir = cache->dirs[i-1]; in clear_cache_files()
869 for (i=0; i<cache->numFiles; i++) { in clear_cache_files()
877 cache_file_t* file = cache->files[i]; in clear_cache_files()
890 void finish_cache_collection(cache_t* cache) in finish_cache_collection() argument
894 CACHE_NOISY(ALOGI("clear_cache_files: %d dirs, %d files\n", cache->numDirs, cache->numFiles)); in finish_cache_collection()
896 for (i=0; i<cache->numDirs; i++) { in finish_cache_collection()
897 cache_dir_t* dir = cache->dirs[i]; in finish_cache_collection()
901 for (i=0; i<cache->numFiles; i++) { in finish_cache_collection()
902 cache_file_t* file = cache->files[i]; in finish_cache_collection()
906 void* block = cache->memBlocks; in finish_cache_collection()
913 free(cache); in finish_cache_collection()