Lines Matching refs:item

46 static int lv_lru_cmp_keys(lv_lru_item_t * item, const void * key, uint32_t key_length);
49 static void lv_lru_remove_item(lv_lru_t * cache, lv_lru_item_t * prev, lv_lru_item_t * item, uint32…
107 lv_lru_item_t * item = NULL, * next = NULL; in lv_lru_del() local
111 item = cache->items[i]; in lv_lru_del()
112 while(item) { in lv_lru_del()
113 next = (lv_lru_item_t *) item->next; in lv_lru_del()
114 cache->value_free(item->value); in lv_lru_del()
115 cache->key_free(item->key); in lv_lru_del()
116 cache->free_memory += item->value_length; in lv_lru_del()
117 lv_mem_free(item); in lv_lru_del()
118 item = next; in lv_lru_del()
125 item = cache->free_items; in lv_lru_del()
126 while(item) { in lv_lru_del()
127 next = (lv_lru_item_t *) item->next; in lv_lru_del()
128 lv_mem_free(item); in lv_lru_del()
129 item = next; in lv_lru_del()
147 lv_lru_item_t * item = NULL, * prev = NULL; in lv_lru_set() local
148 item = cache->items[hash_index]; in lv_lru_set()
150 while(item && lv_lru_cmp_keys(item, key, key_length)) { in lv_lru_set()
151 prev = item; in lv_lru_set()
152 item = (lv_lru_item_t *) item->next; in lv_lru_set()
155 if(item) { in lv_lru_set()
157 required = (int)(value_length - item->value_length); in lv_lru_set()
158 cache->value_free(item->value); in lv_lru_set()
159 item->value = value; in lv_lru_set()
160 item->value_length = value_length; in lv_lru_set()
165 item = lv_lru_pop_or_create_item(cache); in lv_lru_set()
166 item->value = value; in lv_lru_set()
167 item->key = lv_mem_alloc(key_length); in lv_lru_set()
168 memcpy(item->key, key, key_length); in lv_lru_set()
169 item->value_length = value_length; in lv_lru_set()
170 item->key_length = key_length; in lv_lru_set()
174 prev->next = item; in lv_lru_set()
176 cache->items[hash_index] = item; in lv_lru_set()
178 item->access_count = ++cache->access_count; in lv_lru_set()
196 lv_lru_item_t * item = cache->items[hash_index]; in lv_lru_get() local
198 while(item && lv_lru_cmp_keys(item, key, key_size)) in lv_lru_get()
199 item = (lv_lru_item_t *) item->next; in lv_lru_get()
201 if(item) { in lv_lru_get()
202 *value = item->value; in lv_lru_get()
203 item->access_count = ++cache->access_count; in lv_lru_get()
218 lv_lru_item_t * item = NULL, * prev = NULL; in lv_lru_remove() local
220 item = cache->items[hash_index]; in lv_lru_remove()
222 while(item && lv_lru_cmp_keys(item, key, key_size)) { in lv_lru_remove()
223 prev = item; in lv_lru_remove()
224 item = (lv_lru_item_t *) item->next; in lv_lru_remove()
227 if(item) { in lv_lru_remove()
228 lv_lru_remove_item(cache, prev, item, hash_index); in lv_lru_remove()
237 lv_lru_item_t * item = NULL, * prev = NULL; in lv_lru_remove_lru_item() local
242 item = cache->items[i]; in lv_lru_remove_lru_item()
245 while(item) { in lv_lru_remove_lru_item()
246 if(item->access_count < min_access_count || (int64_t) min_access_count == -1) { in lv_lru_remove_lru_item()
247 min_access_count = item->access_count; in lv_lru_remove_lru_item()
248 min_item = item; in lv_lru_remove_lru_item()
252 prev = item; in lv_lru_remove_lru_item()
253 item = item->next; in lv_lru_remove_lru_item()
301 static int lv_lru_cmp_keys(lv_lru_item_t * item, const void * key, uint32_t key_length) in lv_lru_cmp_keys() argument
303 if(key_length != item->key_length) { in lv_lru_cmp_keys()
307 return memcmp(key, item->key, key_length); in lv_lru_cmp_keys()
311 static void lv_lru_remove_item(lv_lru_t * cache, lv_lru_item_t * prev, lv_lru_item_t * item, uint32… in lv_lru_remove_item() argument
314 prev->next = item->next; in lv_lru_remove_item()
317 cache->items[hash_index] = (lv_lru_item_t *) item->next; in lv_lru_remove_item()
321 cache->free_memory += item->value_length; in lv_lru_remove_item()
322 cache->value_free(item->value); in lv_lru_remove_item()
323 cache->key_free(item->key); in lv_lru_remove_item()
326 lv_memset_00(item, sizeof(lv_lru_item_t)); in lv_lru_remove_item()
327 item->next = cache->free_items; in lv_lru_remove_item()
328 cache->free_items = item; in lv_lru_remove_item()
333 lv_lru_item_t * item = NULL; in lv_lru_pop_or_create_item() local
336 item = cache->free_items; in lv_lru_pop_or_create_item()
337 cache->free_items = item->next; in lv_lru_pop_or_create_item()
338 lv_memset_00(item, sizeof(lv_lru_item_t)); in lv_lru_pop_or_create_item()
341 item = (lv_lru_item_t *) lv_mem_alloc(sizeof(lv_lru_item_t)); in lv_lru_pop_or_create_item()
342 lv_memset_00(item, sizeof(lv_lru_item_t)); in lv_lru_pop_or_create_item()
345 return item; in lv_lru_pop_or_create_item()