clrucache · Section 3
ccache_declare
NAME
ccache_declare - declare an uninitialised LRU cache variable with type tracking
LIBRARY
C Collections (libccollections, -lccollections)
SYNOPSIS
#include <ccollections/clrucache.h> ccache_declare(name, KeyT, ValT);
DESCRIPTION
Declares the ccache handle variable name, together with two hidden companion type variables that carry the KeyT and ValT type information into the later ccache_init(), ccache_get() and ccache_set() calls. Call ccache_init() on the variable before you use the cache.
PARAMETERS
name Variable name for the cache handle KeyT Key type (for example int, char *, struct MyKey) ValT Value type (for example double, struct MyVal)
NOTES
An array key type or value type, such as int[2] or char[16], is a compile error, and the message says to wrap the array in a struct. The macros copy a key or a value by assignment, C cannot assign an array, and without the error the cache would store the address of the caller's array instead of its elements. A struct that holds the array works.
EXAMPLES
ccache_declare(cache, int, double); ccache_init(cache, 128, NULL, NULL, NULL); /* ... use cache ... */ ccache_destroy(cache);
SEE ALSO
ccache_declare_scoped(3), ccache_init(3), ccache_construct(3)