Hash :
d1b7475b
Author :
Date :
2000-08-24T16:29:15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
/***************************************************************************/
/* */
/* ftlru.h */
/* */
/* Simple LRU list-cache (specification). */
/* */
/* Copyright 2000 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/***************************************************************************/
#ifndef FTLRU_H
#define FTLRU_H
#include <freetype/freetype.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef FT_Pointer FT_LruKey;
typedef struct FT_LruNodeRec_
{
FT_ListNodeRec root;
FT_LruKey key;
} FT_LruNodeRec, *FT_LruNode;
typedef struct FT_LruRec_* FT_Lru;
typedef struct FT_Lru_Class_
{
FT_UInt lru_size; /* object size in bytes */
FT_Error (*init_element)( FT_Lru lru,
FT_LruNode node );
void (*done_element)( FT_Lru lru,
FT_LruNode node );
FT_Error (*flush_element)( FT_Lru lru,
FT_LruNode node,
FT_LruKey new_key );
FT_Bool (*compare_element)( FT_LruNode node,
FT_LruKey key );
} FT_Lru_Class;
typedef FT_Bool (*FT_Lru_Selector)( FT_Lru lru,
FT_LruNode node,
FT_Pointer data );
typedef struct FT_LruRec_
{
FT_Lru_Class* clazz;
FT_UInt max_elements;
FT_UInt num_elements;
FT_ListRec elements;
FT_Memory memory;
FT_Pointer user_data;
/* the following fields are only meaningful for static lru containers */
FT_ListRec free_nodes;
FT_LruNode nodes;
} FT_LruRec;
FT_EXPORT_DEF( FT_Error ) FT_Lru_New( const FT_Lru_Class* clazz,
FT_UInt max_elements,
FT_Pointer user_data,
FT_Memory memory,
FT_Bool pre_alloc,
FT_Lru* alru );
FT_EXPORT_DEF( void ) FT_Lru_Reset( FT_Lru lru );
FT_EXPORT_DEF( void ) FT_Lru_Done( FT_Lru lru );
FT_EXPORT_DEF( FT_Error ) FT_Lru_Lookup_Node( FT_Lru lru,
FT_LruKey key,
FT_LruNode* anode );
FT_EXPORT_DEF( FT_Error ) FT_Lru_Lookup( FT_Lru lru,
FT_LruKey key,
FT_Pointer* aobject );
FT_EXPORT_DEF( void ) FT_Lru_Remove_Node( FT_Lru lru,
FT_LruNode node );
FT_EXPORT_DEF( void ) FT_Lru_Remove_Selection( FT_Lru lru,
FT_Lru_Selector selector,
FT_Pointer data );
#ifdef __cplusplus
}
#endif
#endif /* FTLRU_H */
/* END */