Files
harbour-core/harbour/contrib/gd/include/gdcache.h
Francesco Saverio Giudice 2373b7f087 2007-04-14 13:36 UTC+0200 Francesco Saverio Giudice (info/at/fsgiudice.com)
* harbour/bin/bld.bat
     * added HB_USER_LIB var to bcc link line to make usable bldtest.bat
       Question: Is there a way to build from bcc adding contrib libs ?

   - harbour/contrib/gd/hbgd.txt
   + harbour/contrib/gd/doc/hbgd.txt
     * moved in doc dir

   + harbour/contrib/gd/doc/COPYING
     + gd copyright text (it's free for any use, but this file has to be
                          reported)

   + harbour/contrib/gd/include/entities.h
   + harbour/contrib/gd/include/gd.h
   + harbour/contrib/gd/include/gd_io.h
   + harbour/contrib/gd/include/gdcache.h
   + harbour/contrib/gd/include/gdfontg.h
   + harbour/contrib/gd/include/gdfontl.h
   + harbour/contrib/gd/include/gdfontmb.h
   + harbour/contrib/gd/include/gdfonts.h
   + harbour/contrib/gd/include/gdfontt.h
   + harbour/contrib/gd/include/gdfx.h
   + harbour/contrib/gd/include/gdhelpers.h
   + harbour/contrib/gd/include/jisx0208.h
   + harbour/contrib/gd/include/wbmp.h
     + include files for compiling in windows environment

   + harbour/contrib/gd/tests/digits/57chevy.gif
   + harbour/contrib/gd/tests/digits/7seg.gif
   + harbour/contrib/gd/tests/digits/brsd.gif
   + harbour/contrib/gd/tests/digits/digib.gif
   + harbour/contrib/gd/tests/digits/fdb.gif
   + harbour/contrib/gd/tests/digits/jelly.gif
   + harbour/contrib/gd/tests/digits/odb.gif
   + harbour/contrib/gd/tests/digits/odw.gif
   + harbour/contrib/gd/tests/digits/pdg.gif
   + harbour/contrib/gd/tests/digits/pdw.gif
     + digits images for counter.prg sample

   + harbour/contrib/gd/gdexternal.ch
     + external declarations for use with linker

   + harbour/contrib/gd/make_b32.bat
   + harbour/contrib/gd/makefile.bc
   + harbour/contrib/gd/tests/bldtest.bat
   + harbour/contrib/gd/tests/bldtest.sh
     + make files

   * harbour/contrib/gd/tests/images_in/conv_test.jpeg
   * harbour/contrib/gd/tests/images_in/gdlogobig.png
   * harbour/contrib/gd/tests/images_in/theclipper.gif
     * updated images (I got them corrupted, probably is CVS ?)

   * harbour/contrib/gd/README
   * harbour/contrib/gd/gd.prg
   * harbour/contrib/gd/gdbar.prg
   * harbour/contrib/gd/gdbarcod.prg
   * harbour/contrib/gd/gdchart.prg
   * harbour/contrib/gd/gdimage.prg
   * harbour/contrib/gd/gdwrp.c
   * harbour/contrib/gd/tests/animgif.prg
   * harbour/contrib/gd/tests/antialiased.prg
   * harbour/contrib/gd/tests/barms.prg
   * harbour/contrib/gd/tests/bartest.prg
   * harbour/contrib/gd/tests/counter.prg
   * harbour/contrib/gd/tests/gdtestcls.prg
   * harbour/contrib/gd/tests/test_out.prg
   * harbour/contrib/gd/tests/testdpi.prg
   * harbour/contrib/gd/tests/tostring.prg
     * fixed hbgd files

     ! Please test in other environment.
       I have built harbour as downloaded from CVS,
       no HB_COMPAT_XHB defined
2007-04-14 11:37:18 +00:00

94 lines
2.7 KiB
C

#ifdef __cplusplus
extern "C" {
#endif
/*
* gdcache.h
*
* Caches of pointers to user structs in which the least-recently-used
* element is replaced in the event of a cache miss after the cache has
* reached a given size.
*
* John Ellson (ellson@graphviz.org) Oct 31, 1997
*
* Test this with:
* gcc -o gdcache -g -Wall -DTEST gdcache.c
*
* The cache is implemented by a singly-linked list of elements
* each containing a pointer to a user struct that is being managed by
* the cache.
*
* The head structure has a pointer to the most-recently-used
* element, and elements are moved to this position in the list each
* time they are used. The head also contains pointers to three
* user defined functions:
* - a function to test if a cached userdata matches some keydata
* - a function to provide a new userdata struct to the cache
* if there has been a cache miss.
* - a function to release a userdata struct when it is
* no longer being managed by the cache
*
* In the event of a cache miss the cache is allowed to grow up to
* a specified maximum size. After the maximum size is reached then
* the least-recently-used element is discarded to make room for the
* new. The most-recently-returned value is always left at the
* beginning of the list after retrieval.
*
* In the current implementation the cache is traversed by a linear
* search from most-recent to least-recent. This linear search
* probably limits the usefulness of this implementation to cache
* sizes of a few tens of elements.
*/
/*********************************************************/
/* header */
/*********************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#ifndef NULL
#define NULL (void *)0
#endif
/* user defined function templates */
typedef int (*gdCacheTestFn_t) (void *userdata, void *keydata);
typedef void *(*gdCacheFetchFn_t) (char **error, void *keydata);
typedef void (*gdCacheReleaseFn_t) (void *userdata);
/* element structure */
typedef struct gdCache_element_s gdCache_element_t;
struct gdCache_element_s
{
gdCache_element_t *next;
void *userdata;
};
/* head structure */
typedef struct gdCache_head_s gdCache_head_t;
struct gdCache_head_s
{
gdCache_element_t *mru;
int size;
char *error;
gdCacheTestFn_t gdCacheTest;
gdCacheFetchFn_t gdCacheFetch;
gdCacheReleaseFn_t gdCacheRelease;
};
/* function templates */
gdCache_head_t *gdCacheCreate (int size,
gdCacheTestFn_t gdCacheTest,
gdCacheFetchFn_t gdCacheFetch,
gdCacheReleaseFn_t gdCacheRelease);
void gdCacheDelete (gdCache_head_t * head);
void *gdCacheGet (gdCache_head_t * head, void *keydata);
#ifdef __cplusplus
}
#endif