php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
gdcache.h
Go to the documentation of this file.
1/*
2 * gdcache.h
3 *
4 * Caches of pointers to user structs in which the least-recently-used
5 * element is replaced in the event of a cache miss after the cache has
6 * reached a given size.
7 *
8 * John Ellson (ellson@graphviz.org) Oct 31, 1997
9 *
10 * Test this with:
11 * gcc -o gdcache -g -Wall -DTEST gdcache.c
12 *
13 * The cache is implemented by a singly-linked list of elements
14 * each containing a pointer to a user struct that is being managed by
15 * the cache.
16 *
17 * The head structure has a pointer to the most-recently-used
18 * element, and elements are moved to this position in the list each
19 * time they are used. The head also contains pointers to three
20 * user defined functions:
21 * - a function to test if a cached userdata matches some keydata
22 * - a function to provide a new userdata struct to the cache
23 * if there has been a cache miss.
24 * - a function to release a userdata struct when it is
25 * no longer being managed by the cache
26 *
27 * In the event of a cache miss the cache is allowed to grow up to
28 * a specified maximum size. After the maximum size is reached then
29 * the least-recently-used element is discarded to make room for the
30 * new. The most-recently-returned value is always left at the
31 * beginning of the list after retrieval.
32 *
33 * In the current implementation the cache is traversed by a linear
34 * search from most-recent to least-recent. This linear search
35 * probably limits the usefulness of this implementation to cache
36 * sizes of a few tens of elements.
37 */
38
39/*********************************************************/
40/* header */
41/*********************************************************/
42
43#include <stdlib.h>
44#ifndef NULL
45#define NULL (void *)0
46#endif
47
48/* user defined function templates */
49typedef int (*gdCacheTestFn_t)(void *userdata, void *keydata);
50typedef void *(*gdCacheFetchFn_t)(char **error, void *keydata);
51typedef void (*gdCacheReleaseFn_t)(void *userdata);
52
53/* element structure */
59
60/* head structure */
70
71/* function templates */
74 int size,
75 gdCacheTestFn_t gdCacheTest,
76 gdCacheFetchFn_t gdCacheFetch,
77 gdCacheReleaseFn_t gdCacheRelease );
78
79void
81
82void *
83gdCacheGet( gdCache_head_t *head, void *keydata );
error($message)
Definition ext_skel.php:22
new_type size
Definition ffi.c:4365
void(* gdCacheReleaseFn_t)(void *userdata)
Definition gdcache.h:51
void gdCacheDelete(gdCache_head_t *head)
gdCache_head_t * gdCacheCreate(int size, gdCacheTestFn_t gdCacheTest, gdCacheFetchFn_t gdCacheFetch, gdCacheReleaseFn_t gdCacheRelease)
void * gdCacheGet(gdCache_head_t *head, void *keydata)
void *(* gdCacheFetchFn_t)(char **error, void *keydata)
Definition gdcache.h:50
struct gdCache_head_s gdCache_head_t
Definition gdcache.h:61
struct gdCache_element_s gdCache_element_t
Definition gdcache.h:54
int(* gdCacheTestFn_t)(void *userdata, void *keydata)
Definition gdcache.h:49
struct php_pcntl_pending_signal * head
Definition php_pcntl.h:47
gdCache_element_t * next
Definition gdcache.h:56
void * userdata
Definition gdcache.h:57
gdCacheReleaseFn_t gdCacheRelease
Definition gdcache.h:68
char * error
Definition gdcache.h:65
gdCacheTestFn_t gdCacheTest
Definition gdcache.h:66
gdCache_element_t * mru
Definition gdcache.h:63
gdCacheFetchFn_t gdCacheFetch
Definition gdcache.h:67
ZEND_API void(ZEND_FASTCALL *zend_touch_vm_stack_data)(void *vm_stack_data)