MCPcopy Create free account
hub / github.com/1a1a11a/libCacheSim / RandomLRU_init

Function RandomLRU_init

libCacheSim/cache/eviction/RandomLRU.c:55–81  ·  view source on GitHub ↗

end user facing functions init, free, get * @brief initialize a RandomLRU cache * * @param ccache_params some common cache parameters * @param cache_specific_params RandomLRU specific parameters, should be NULL */

Source from the content-addressed store, hash-verified

53 * @param cache_specific_params RandomLRU specific parameters, should be NULL
54 */
55cache_t *RandomLRU_init(const common_cache_params_t ccache_params, const char *cache_specific_params) {
56 common_cache_params_t ccache_params_copy = ccache_params;
57 ccache_params_copy.hashpower = MAX(12, ccache_params_copy.hashpower - 8);
58
59 cache_t *cache = cache_struct_init("RandomLRU", ccache_params_copy, cache_specific_params);
60 cache->cache_init = RandomLRU_init;
61 cache->cache_free = RandomLRU_free;
62 cache->get = RandomLRU_get;
63 cache->find = RandomLRU_find;
64 cache->insert = RandomLRU_insert;
65 cache->to_evict = RandomLRU_to_evict;
66 cache->evict = RandomLRU_evict;
67 cache->remove = RandomLRU_remove;
68
69 cache->eviction_params = (RandomLRU_params_t *)malloc(sizeof(RandomLRU_params_t));
70 RandomLRU_params_t *params = (RandomLRU_params_t *)(cache->eviction_params);
71 memset(params, 0, sizeof(RandomLRU_params_t));
72
73 RandomLRU_parse_params(cache, DEFAULT_CACHE_PARAMS);
74 if (cache_specific_params != NULL) {
75 RandomLRU_parse_params(cache, cache_specific_params);
76 }
77
78 snprintf(cache->cache_name, CACHE_NAME_ARRAY_LEN, "RandomLRU-%d", params->n_samples);
79
80 return cache;
81}
82
83/**
84 * free resources used by this cache

Callers 1

create_cacheFunction · 0.85

Calls 2

cache_struct_initFunction · 0.85
RandomLRU_parse_paramsFunction · 0.85

Tested by

no test coverage detected