diff options
Diffstat (limited to 'src/lib/third_party/include/libcache.h')
-rw-r--r-- | src/lib/third_party/include/libcache.h | 84 |
1 files changed, 32 insertions, 52 deletions
diff --git a/src/lib/third_party/include/libcache.h b/src/lib/third_party/include/libcache.h index f959b3a9c..1f240854f 100644 --- a/src/lib/third_party/include/libcache.h +++ b/src/lib/third_party/include/libcache.h @@ -1,65 +1,45 @@ -#ifndef __LIBCACHE_H__ -#define __LIBCACHE_H__ - -#include <stdint.h> - - -/* Codes representing the result of some functions */ -typedef enum { - CACHE_NO_ERROR = 0, - CACHE_CONTAINS_FALSE = 0, - CACHE_CONTAINS_TRUE, - CACHE_INVALID_INPUT, - CACHE_REMOVE_NOT_FOUND, - CACHE_MALLOC_ERROR -} cache_result; - -/* CACHE_T */ -typedef struct cache_t cache_t; +/** + * @file libcache.h + * @author William Guglielmo <william@deselmo.com> + * @brief File containing header of cache_t type. + * + */ -/* CACHE_ENTRY */ -typedef struct cache_entry cache_entry; -/* CACHE_ENTRY_MAP */ -typedef struct cache_entry_map cache_entry_map; +#ifndef __DESELMO_LIBCACHE_H__ +#define __DESELMO_LIBCACHE_H__ +#include <stdint.h> -/* STRUCT CACHE_T */ -struct cache_t { - uint32_t size; - uint32_t max_size; - cache_entry *head; - cache_entry *tail; - cache_entry_map **map; -}; +/** + * @brief Codes representing the result of some functions + * + */ +typedef enum cache_result { + CACHE_NO_ERROR = 0, /**< Returned by a function if no error occurs. */ + CACHE_CONTAINS_FALSE = 0, /**< Returned by function cache_contains if item is not present. */ + CACHE_CONTAINS_TRUE, /**< Returned by function cache_contains if item is present. */ + CACHE_INVALID_INPUT, /**< Returned by a function if it is called with invalid input parameters. */ + CACHE_REMOVE_NOT_FOUND, /**< Returned by function cache_remove if item is not present. */ + CACHE_MALLOC_ERROR /**< Returned by a function if a malloc fail. */ +} cache_result; -/* STRUCT CACHE_ENTRY */ -struct cache_entry_map { - cache_entry *entry; - cache_entry_map *next; -}; -/* STRUCT CACHE_ENTRY_MAP */ -struct cache_entry { - void *item; - uint32_t item_size; - cache_entry *prev; - cache_entry *next; -}; +typedef struct cache_t *cache_t; /** - * Returns a new cache_t + * @brief Returns a new cache_t * * @par cache_max_size = max number of item that the new cache_t can contain * @return a new cache_t, or NULL if an error occurred * */ -cache_t *cache_new(uint32_t cache_max_size); +cache_t cache_new(uint32_t cache_max_size); /** - * Add an item in the specified cache_t + * @brief Add an item in the specified cache_t * * @par cache = the cache_t * @par item = pointer to the item to add @@ -67,11 +47,11 @@ cache_t *cache_new(uint32_t cache_max_size); * @return a code representing the result of the function * */ -cache_result cache_add(cache_t *cache, void *item, uint32_t item_size); +cache_result cache_add(cache_t cache, void *item, uint32_t item_size); /** - * Check if an item is in the specified cache_t + * @brief Check if an item is in the specified cache_t * * @par cache = the cache_t * @par item = pointer to the item to check @@ -79,11 +59,11 @@ cache_result cache_add(cache_t *cache, void *item, uint32_t item_size); * @return a code representing the result of the function * */ -cache_result cache_contains(cache_t *cache, void *item, uint32_t item_size); +cache_result cache_contains(cache_t cache, void *item, uint32_t item_size); /** - * Remove an item in the specified cache_t + * @brief Remove an item in the specified cache_t * * @par cache = the cache_t * @par item = pointer to the item to remove @@ -91,15 +71,15 @@ cache_result cache_contains(cache_t *cache, void *item, uint32_t item_size); * @return a code representing the result of the function * */ -cache_result cache_remove(cache_t *cache, void *item, uint32_t item_size); +cache_result cache_remove(cache_t cache, void *item, uint32_t item_size); /** - * Free the specified cache_t + * @brief Free the specified cache_t * * @par alist = the cache * */ -void cache_free(cache_t *cache); +void cache_free(cache_t cache); #endif |