clrucache · Section 3
ccache_declare_scoped
NAME
ccache_declare_scoped - declare an LRU cache that is destroyed at scope exit
LIBRARY
C Collections (libccollections, -lccollections)
SYNOPSIS
#include <ccollections/clrucache.h> ccache_declare_scoped(name, KeyT, ValT);
DESCRIPTION
The same as ccache_declare(), plus __attribute__((cleanup(clrucache__destroy_cleanup))) on the variable, so the compiler destroys the cache when the variable leaves its scope. Call ccache_init() on the variable before you use the cache.
PARAMETERS
name Variable name for the cache handle KeyT Key type ValT Value type
NOTES
The macro needs GCC or Clang, because it uses __attribute__((cleanup)). 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.