Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../proc/self/root/usr/include
File: gdcache.h
#ifdef __cplusplus
[0] Fix | Delete
extern "C" {
[1] Fix | Delete
#endif
[2] Fix | Delete
[3] Fix | Delete
/*
[4] Fix | Delete
* gdcache.h
[5] Fix | Delete
*
[6] Fix | Delete
* Caches of pointers to user structs in which the least-recently-used
[7] Fix | Delete
* element is replaced in the event of a cache miss after the cache has
[8] Fix | Delete
* reached a given size.
[9] Fix | Delete
*
[10] Fix | Delete
* John Ellson (ellson@graphviz.org) Oct 31, 1997
[11] Fix | Delete
*
[12] Fix | Delete
* Test this with:
[13] Fix | Delete
* gcc -o gdcache -g -Wall -DTEST gdcache.c
[14] Fix | Delete
*
[15] Fix | Delete
* The cache is implemented by a singly-linked list of elements
[16] Fix | Delete
* each containing a pointer to a user struct that is being managed by
[17] Fix | Delete
* the cache.
[18] Fix | Delete
*
[19] Fix | Delete
* The head structure has a pointer to the most-recently-used
[20] Fix | Delete
* element, and elements are moved to this position in the list each
[21] Fix | Delete
* time they are used. The head also contains pointers to three
[22] Fix | Delete
* user defined functions:
[23] Fix | Delete
* - a function to test if a cached userdata matches some keydata
[24] Fix | Delete
* - a function to provide a new userdata struct to the cache
[25] Fix | Delete
* if there has been a cache miss.
[26] Fix | Delete
* - a function to release a userdata struct when it is
[27] Fix | Delete
* no longer being managed by the cache
[28] Fix | Delete
*
[29] Fix | Delete
* In the event of a cache miss the cache is allowed to grow up to
[30] Fix | Delete
* a specified maximum size. After the maximum size is reached then
[31] Fix | Delete
* the least-recently-used element is discarded to make room for the
[32] Fix | Delete
* new. The most-recently-returned value is always left at the
[33] Fix | Delete
* beginning of the list after retrieval.
[34] Fix | Delete
*
[35] Fix | Delete
* In the current implementation the cache is traversed by a linear
[36] Fix | Delete
* search from most-recent to least-recent. This linear search
[37] Fix | Delete
* probably limits the usefulness of this implementation to cache
[38] Fix | Delete
* sizes of a few tens of elements.
[39] Fix | Delete
*/
[40] Fix | Delete
[41] Fix | Delete
/*********************************************************/
[42] Fix | Delete
/* header */
[43] Fix | Delete
/*********************************************************/
[44] Fix | Delete
[45] Fix | Delete
#include <stdlib.h>
[46] Fix | Delete
#ifndef NULL
[47] Fix | Delete
# define NULL (void *)0
[48] Fix | Delete
#endif
[49] Fix | Delete
[50] Fix | Delete
/* user defined function templates */
[51] Fix | Delete
typedef int (*gdCacheTestFn_t)(void *userdata, void *keydata);
[52] Fix | Delete
typedef void *(*gdCacheFetchFn_t)(char **error, void *keydata);
[53] Fix | Delete
typedef void (*gdCacheReleaseFn_t)(void *userdata);
[54] Fix | Delete
[55] Fix | Delete
/* element structure */
[56] Fix | Delete
typedef struct gdCache_element_s gdCache_element_t;
[57] Fix | Delete
struct gdCache_element_s {
[58] Fix | Delete
gdCache_element_t *next;
[59] Fix | Delete
void *userdata;
[60] Fix | Delete
};
[61] Fix | Delete
[62] Fix | Delete
/* head structure */
[63] Fix | Delete
typedef struct gdCache_head_s gdCache_head_t;
[64] Fix | Delete
struct gdCache_head_s {
[65] Fix | Delete
gdCache_element_t *mru;
[66] Fix | Delete
int size;
[67] Fix | Delete
char *error;
[68] Fix | Delete
gdCacheTestFn_t gdCacheTest;
[69] Fix | Delete
gdCacheFetchFn_t gdCacheFetch;
[70] Fix | Delete
gdCacheReleaseFn_t gdCacheRelease;
[71] Fix | Delete
};
[72] Fix | Delete
[73] Fix | Delete
/* function templates */
[74] Fix | Delete
gdCache_head_t *gdCacheCreate(int size,
[75] Fix | Delete
gdCacheTestFn_t gdCacheTest,
[76] Fix | Delete
gdCacheFetchFn_t gdCacheFetch,
[77] Fix | Delete
gdCacheReleaseFn_t gdCacheRelease
[78] Fix | Delete
);
[79] Fix | Delete
[80] Fix | Delete
void gdCacheDelete(gdCache_head_t *head);
[81] Fix | Delete
[82] Fix | Delete
void *gdCacheGet(gdCache_head_t *head, void *keydata);
[83] Fix | Delete
[84] Fix | Delete
#ifdef __cplusplus
[85] Fix | Delete
}
[86] Fix | Delete
#endif
[87] Fix | Delete
[88] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function