mikroSDK Reference Manual
lv_lru.h
Go to the documentation of this file.
1
6#ifndef LV_LRU_H
7#define LV_LRU_H
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13/*********************
14 * INCLUDES
15 *********************/
16
17#include "../lv_conf_internal.h"
18
19#include "lv_types.h"
20
21#include <stdint.h>
22#include <stddef.h>
23
24
25/*********************
26 * DEFINES
27 *********************/
28
29/**********************
30 * TYPEDEFS
31 **********************/
32
33typedef enum {
34 LV_LRU_OK = 0,
35 LV_LRU_MISSING_CACHE,
36 LV_LRU_MISSING_KEY,
37 LV_LRU_MISSING_VALUE,
38 LV_LRU_LOCK_ERROR,
39 LV_LRU_VALUE_TOO_LARGE
40} lv_lru_res_t;
41
42typedef void (lv_lru_free_t)(void * v);
43typedef struct _lv_lru_item_t lv_lru_item_t;
44
45typedef struct lv_lru_t {
46 lv_lru_item_t ** items;
47 uint64_t access_count;
48 size_t free_memory;
49 size_t total_memory;
50 size_t average_item_length;
51 size_t hash_table_size;
52 uint32_t seed;
53 lv_lru_free_t * value_free;
54 lv_lru_free_t * key_free;
55 lv_lru_item_t * free_items;
56} lv_lru_t;
57
58
59/**********************
60 * GLOBAL PROTOTYPES
61 **********************/
62
63lv_lru_t * lv_lru_create(size_t cache_size, size_t average_length, lv_lru_free_t * value_free,
64 lv_lru_free_t * key_free);
65
66void lv_lru_del(lv_lru_t * cache);
67
68lv_lru_res_t lv_lru_set(lv_lru_t * cache, const void * key, size_t key_length, void * value, size_t value_length);
69
70lv_lru_res_t lv_lru_get(lv_lru_t * cache, const void * key, size_t key_size, void ** value);
71
72lv_lru_res_t lv_lru_remove(lv_lru_t * cache, const void * key, size_t key_size);
73
80/**********************
81 * MACROS
82 **********************/
83#ifdef __cplusplus
84} /*extern "C"*/
85#endif
86
87#endif /*LV_LRU_H*/
void lv_lru_remove_lru_item(lv_lru_t *cache)
Definition lv_lru.h:45