acid-drop

- Hacking the planet from a LilyGo T-Deck using custom firmware
git clone git://git.acid.vegas/acid-drop.git
Log | Files | Refs | Archive | README | LICENSE

lv_lru.h (1655B)

      1 /**
      2  * @file lv_lru.h
      3  *
      4  */
      5 
      6 #ifndef LV_LRU_H
      7 #define LV_LRU_H
      8 
      9 #ifdef __cplusplus
     10 extern "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 
     33 typedef 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 
     42 typedef void (lv_lru_free_t)(void * v);
     43 typedef struct _lv_lru_item_t lv_lru_item_t;
     44 
     45 typedef 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 
     63 lv_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 
     66 void lv_lru_del(lv_lru_t * cache);
     67 
     68 lv_lru_res_t lv_lru_set(lv_lru_t * cache, const void * key, size_t key_length, void * value, size_t value_length);
     69 
     70 lv_lru_res_t lv_lru_get(lv_lru_t * cache, const void * key, size_t key_size, void ** value);
     71 
     72 lv_lru_res_t lv_lru_remove(lv_lru_t * cache, const void * key, size_t key_size);
     73 
     74 /**********************
     75  *      MACROS
     76  **********************/
     77 #ifdef __cplusplus
     78 } /*extern "C"*/
     79 #endif
     80 
     81 #endif /*LV_LRU_H*/