cache_callbacks(3) Library Functions Manual cache_callbacks(3)

cache_callbacksPre-defined cache callbacks used to configure a cache

#include <cache.h>
#include <cache_callbacks.h>

uintptr_t
cache_key_hash_cb_cstring(void *key, void *unused);

uintptr_t
cache_key_hash_cb_integer(void *key, void *unused);

bool
cache_key_is_equal_cb_cstring(void *key1, void *key2, void *unused);

bool
cache_key_is_equal_cb_integer(void *key1, void *key2, void *unused);

void
cache_release_cb_free(void *key_or_value, void *unused);

void
cache_value_make_purgeable_cb(void *value, void *unused);

bool
cache_value_make_nonpurgeable_cb(void *value, void *unused);

uintptr_t
cache_hash_byte_string(const char *data, size_t bytes);

These functions are intended to be used as callbacks to configure how a cache functions. They should be set in the cache_attributes_t passed into cache_create. They support common key types and offer support for using purgeable memory to allocate cache values.

() A () function for NULL-terminated cstring keys.

() A () function for integer keys.

() A () function for cstring keys.

() A () function for integer keys.

() Can be used for () or () for keys/values allocated from malloc and family.

() Can be used for () with values allocated from the purgeable malloc zone (see malloc/malloc.h). Calls () on value when it is unreferenced in order to reduce paging under memory pressure.

() Can be used for () with values allocated from the purgeable malloc zone (see malloc/malloc.h). Calls () on value when it is referenced in order to make a value nonpurgeable.

() Calculates a hash from a bytes string data of length bytes.

libcache(3) cache_create(3)

May 7, 2009 Darwin