ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

ftcmru.h
Go to the documentation of this file.
00001 /***************************************************************************/
00002 /*                                                                         */
00003 /*  ftcmru.h                                                               */
00004 /*                                                                         */
00005 /*    Simple MRU list-cache (specification).                               */
00006 /*                                                                         */
00007 /*  Copyright 2000-2001, 2003, 2004, 2005, 2006, 2010 by                   */
00008 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
00009 /*                                                                         */
00010 /*  This file is part of the FreeType project, and may only be used,       */
00011 /*  modified, and distributed under the terms of the FreeType project      */
00012 /*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
00013 /*  this file you indicate that you have read the license and              */
00014 /*  understand and accept it fully.                                        */
00015 /*                                                                         */
00016 /***************************************************************************/
00017 
00018 
00019   /*************************************************************************/
00020   /*                                                                       */
00021   /* An MRU is a list that cannot hold more than a certain number of       */
00022   /* elements (`max_elements').  All elements in the list are sorted in    */
00023   /* least-recently-used order, i.e., the `oldest' element is at the tail  */
00024   /* of the list.                                                          */
00025   /*                                                                       */
00026   /* When doing a lookup (either through `Lookup()' or `Lookup_Node()'),   */
00027   /* the list is searched for an element with the corresponding key.  If   */
00028   /* it is found, the element is moved to the head of the list and is      */
00029   /* returned.                                                             */
00030   /*                                                                       */
00031   /* If no corresponding element is found, the lookup routine will try to  */
00032   /* obtain a new element with the relevant key.  If the list is already   */
00033   /* full, the oldest element from the list is discarded and replaced by a */
00034   /* new one; a new element is added to the list otherwise.                */
00035   /*                                                                       */
00036   /* Note that it is possible to pre-allocate the element list nodes.      */
00037   /* This is handy if `max_elements' is sufficiently small, as it saves    */
00038   /* allocations/releases during the lookup process.                       */
00039   /*                                                                       */
00040   /*************************************************************************/
00041 
00042 
00043 #ifndef __FTCMRU_H__
00044 #define __FTCMRU_H__
00045 
00046 
00047 #include <ft2build.h>
00048 #include FT_FREETYPE_H
00049 
00050 #ifdef FREETYPE_H
00051 #error "freetype.h of FreeType 1 has been loaded!"
00052 #error "Please fix the directory search order for header files"
00053 #error "so that freetype.h of FreeType 2 is found first."
00054 #endif
00055 
00056 #define  xxFT_DEBUG_ERROR
00057 #define  FTC_INLINE
00058 
00059 FT_BEGIN_HEADER
00060 
00061   typedef struct FTC_MruNodeRec_*  FTC_MruNode;
00062 
00063   typedef struct  FTC_MruNodeRec_
00064   {
00065     FTC_MruNode  next;
00066     FTC_MruNode  prev;
00067 
00068   } FTC_MruNodeRec;
00069 
00070 
00071   FT_LOCAL( void )
00072   FTC_MruNode_Prepend( FTC_MruNode  *plist,
00073                        FTC_MruNode   node );
00074 
00075   FT_LOCAL( void )
00076   FTC_MruNode_Up( FTC_MruNode  *plist,
00077                   FTC_MruNode   node );
00078 
00079   FT_LOCAL( void )
00080   FTC_MruNode_Remove( FTC_MruNode  *plist,
00081                       FTC_MruNode   node );
00082 
00083 
00084   typedef struct FTC_MruListRec_*              FTC_MruList;
00085 
00086   typedef struct FTC_MruListClassRec_ const *  FTC_MruListClass;
00087 
00088 
00089   typedef FT_Bool
00090   (*FTC_MruNode_CompareFunc)( FTC_MruNode  node,
00091                               FT_Pointer   key );
00092 
00093   typedef FT_Error
00094   (*FTC_MruNode_InitFunc)( FTC_MruNode  node,
00095                            FT_Pointer   key,
00096                            FT_Pointer   data );
00097 
00098   typedef FT_Error
00099   (*FTC_MruNode_ResetFunc)( FTC_MruNode  node,
00100                             FT_Pointer   key,
00101                             FT_Pointer   data );
00102 
00103   typedef void
00104   (*FTC_MruNode_DoneFunc)( FTC_MruNode  node,
00105                            FT_Pointer   data );
00106 
00107 
00108   typedef struct  FTC_MruListClassRec_
00109   {
00110     FT_Offset                node_size;
00111     FTC_MruNode_CompareFunc  node_compare;
00112     FTC_MruNode_InitFunc     node_init;
00113     FTC_MruNode_ResetFunc    node_reset;
00114     FTC_MruNode_DoneFunc     node_done;
00115 
00116   } FTC_MruListClassRec;
00117 
00118   typedef struct  FTC_MruListRec_
00119   {
00120     FT_UInt              num_nodes;
00121     FT_UInt              max_nodes;
00122     FTC_MruNode          nodes;
00123     FT_Pointer           data;
00124     FTC_MruListClassRec  clazz;
00125     FT_Memory            memory;
00126 
00127   } FTC_MruListRec;
00128 
00129 
00130   FT_LOCAL( void )
00131   FTC_MruList_Init( FTC_MruList       list,
00132                     FTC_MruListClass  clazz,
00133                     FT_UInt           max_nodes,
00134                     FT_Pointer        data,
00135                     FT_Memory         memory );
00136 
00137   FT_LOCAL( void )
00138   FTC_MruList_Reset( FTC_MruList  list );
00139 
00140 
00141   FT_LOCAL( void )
00142   FTC_MruList_Done( FTC_MruList  list );
00143 
00144 
00145   FT_LOCAL( FT_Error )
00146   FTC_MruList_New( FTC_MruList   list,
00147                    FT_Pointer    key,
00148                    FTC_MruNode  *anode );
00149 
00150   FT_LOCAL( void )
00151   FTC_MruList_Remove( FTC_MruList  list,
00152                       FTC_MruNode  node );
00153 
00154   FT_LOCAL( void )
00155   FTC_MruList_RemoveSelection( FTC_MruList              list,
00156                                FTC_MruNode_CompareFunc  selection,
00157                                FT_Pointer               key );
00158 
00159 
00160 #ifdef FTC_INLINE
00161 
00162 #define FTC_MRULIST_LOOKUP_CMP( list, key, compare, node, error )           \
00163   FT_BEGIN_STMNT                                                            \
00164     FTC_MruNode*             _pfirst  = &(list)->nodes;                     \
00165     FTC_MruNode_CompareFunc  _compare = (FTC_MruNode_CompareFunc)(compare); \
00166     FTC_MruNode              _first, _node;                                 \
00167                                                                             \
00168                                                                             \
00169     error  = FTC_Err_Ok;                                                    \
00170     _first = *(_pfirst);                                                    \
00171     _node  = NULL;                                                          \
00172                                                                             \
00173     if ( _first )                                                           \
00174     {                                                                       \
00175       _node = _first;                                                       \
00176       do                                                                    \
00177       {                                                                     \
00178         if ( _compare( _node, (key) ) )                                     \
00179         {                                                                   \
00180           if ( _node != _first )                                            \
00181             FTC_MruNode_Up( _pfirst, _node );                               \
00182                                                                             \
00183           node = _node;                                                     \
00184           goto _MruOk;                                                      \
00185         }                                                                   \
00186         _node = _node->next;                                                \
00187                                                                             \
00188       } while ( _node != _first) ;                                          \
00189     }                                                                       \
00190                                                                             \
00191     error = FTC_MruList_New( (list), (key), (FTC_MruNode*)(void*)&(node) ); \
00192   _MruOk:                                                                   \
00193     ;                                                                       \
00194   FT_END_STMNT
00195 
00196 #define FTC_MRULIST_LOOKUP( list, key, node, error ) \
00197   FTC_MRULIST_LOOKUP_CMP( list, key, (list)->clazz.node_compare, node, error )
00198 
00199 #else  /* !FTC_INLINE */
00200 
00201   FT_LOCAL( FTC_MruNode )
00202   FTC_MruList_Find( FTC_MruList  list,
00203                     FT_Pointer   key );
00204 
00205   FT_LOCAL( FT_Error )
00206   FTC_MruList_Lookup( FTC_MruList   list,
00207                       FT_Pointer    key,
00208                       FTC_MruNode  *pnode );
00209 
00210 #define FTC_MRULIST_LOOKUP( list, key, node, error ) \
00211   error = FTC_MruList_Lookup( (list), (key), (FTC_MruNode*)&(node) )
00212 
00213 #endif /* !FTC_INLINE */
00214 
00215 
00216 #define FTC_MRULIST_LOOP( list, node )        \
00217   FT_BEGIN_STMNT                              \
00218     FTC_MruNode  _first = (list)->nodes;      \
00219                                               \
00220                                               \
00221     if ( _first )                             \
00222     {                                         \
00223       FTC_MruNode  _node = _first;            \
00224                                               \
00225                                               \
00226       do                                      \
00227       {                                       \
00228         *(FTC_MruNode*)&(node) = _node;
00229 
00230 
00231 #define FTC_MRULIST_LOOP_END()               \
00232         _node = _node->next;                 \
00233                                              \
00234       } while ( _node != _first );           \
00235     }                                        \
00236   FT_END_STMNT
00237 
00238  /* */
00239 
00240 FT_END_HEADER
00241 
00242 
00243 #endif /* __FTCMRU_H__ */
00244 
00245 
00246 /* END */

Generated on Sun May 27 2012 04:33:48 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.