libgutenprint API Reference 5.3.4-2022-06-24T01-00-8808d602
Functions
refcache.h File Reference

A simple reference cache. More...

#include <gutenprint/string-list.h>

Functions

int stp_refcache_create (const char *name)
 Create a new object cache. More...
 
void * stp_refcache_find_item (const char *cache, const char *item)
 Find an item in a cache. More...
 
int stp_refcache_add_item (const char *cache, const char *item, void *data)
 Add an item to a cache. More...
 
void stp_refcache_remove_item (const char *cache, const char *item)
 Remove an item from cache. More...
 
void stp_refcache_replace_item (const char *cache, const char *item, void *data)
 Replace an item's data, or add if it doesn't exist. More...
 
void stp_refcache_destroy (const char *cache)
 Destroy a cache. More...
 
const stp_string_list_tstp_refcache_list_caches (void)
 Return a static list of all caches in existence. More...
 
const stp_string_list_tstp_refcache_list_cache_items (const char *cache)
 Return a static list of items in a specified cache. More...
 

Detailed Description

A simple reference cache.

Function Documentation

◆ stp_refcache_add_item()

int stp_refcache_add_item ( const char *  cache,
const char *  item,
void *  data 
)

Add an item to a cache.

Parameters
cachethe cache to use or create.
itemthe name of the item to cache
datapointer to the data item to store
Returns
true if item added; false if already exists

◆ stp_refcache_create()

int stp_refcache_create ( const char *  name)

Create a new object cache.

Parameters
nameThe name of the cache to create
Returns
True if created, false if cache already exists.

◆ stp_refcache_destroy()

void stp_refcache_destroy ( const char *  cache)

Destroy a cache.

The individual items are not freed. If cache does not exist this is a no-op.

Parameters
cachethe cache to destroy.

◆ stp_refcache_find_item()

void * stp_refcache_find_item ( const char *  cache,
const char *  item 
)

Find an item in a cache.

Parameters
cachethe cache to use.
itemthe name of the item to cache
Returns
item if exists, NULL otherwise

◆ stp_refcache_list_cache_items()

const stp_string_list_t * stp_refcache_list_cache_items ( const char *  cache)

Return a static list of items in a specified cache.

Parameters
cachename of cache
Returns
list of items in cache or NULL if cache does not exist

◆ stp_refcache_list_caches()

const stp_string_list_t * stp_refcache_list_caches ( void  )

Return a static list of all caches in existence.

Returns
list of caches in existence

◆ stp_refcache_remove_item()

void stp_refcache_remove_item ( const char *  cache,
const char *  item 
)

Remove an item from cache.

The item's data is not freed. If cache or item does not exist this is a no-op.

Parameters
cachethe cache to use.
itemthe name of the item to remove from cache

◆ stp_refcache_replace_item()

void stp_refcache_replace_item ( const char *  cache,
const char *  item,
void *  data 
)

Replace an item's data, or add if it doesn't exist.

The old data (if any) is not freed. Fails if cache does not already exist.

Parameters
cachethe cache to use.
itemthe name of the item to add/update.
datathe data to be added/updated for the cached item.