godot/thirdparty/freetype/src/cache/ftcmru.h

/****************************************************************************
 *
 * ftcmru.h
 *
 *   Simple MRU list-cache (specification).
 *
 * Copyright (C) 2000-2023 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.
 *
 */


  /**************************************************************************
   *
   * An MRU is a list that cannot hold more than a certain number of
   * elements (`max_elements').  All elements in the list are sorted in
   * least-recently-used order, i.e., the `oldest' element is at the tail
   * of the list.
   *
   * When doing a lookup (either through `Lookup()' or `Lookup_Node()'),
   * the list is searched for an element with the corresponding key.  If
   * it is found, the element is moved to the head of the list and is
   * returned.
   *
   * If no corresponding element is found, the lookup routine will try to
   * obtain a new element with the relevant key.  If the list is already
   * full, the oldest element from the list is discarded and replaced by a
   * new one; a new element is added to the list otherwise.
   *
   * Note that it is possible to pre-allocate the element list nodes.
   * This is handy if `max_elements' is sufficiently small, as it saves
   * allocations/releases during the lookup process.
   *
   */


#ifndef FTCMRU_H_
#define FTCMRU_H_


#include <freetype/freetype.h>
#include <freetype/internal/compiler-macros.h>

#ifdef FREETYPE_H
#error "freetype.h of FreeType 1 has been loaded!"
#error "Please fix the directory search order for header files"
#error "so that freetype.h of FreeType 2 is found first."
#endif

#define xxFT_DEBUG_ERROR
#define FTC_INLINE

FT_BEGIN_HEADER

  FTC_MruNode;

  FTC_MruNodeRec;


  FT_LOCAL( void )
  FTC_MruNode_Prepend( FTC_MruNode  *plist,
                       FTC_MruNode   node );

  FT_LOCAL( void )
  FTC_MruNode_Up( FTC_MruNode  *plist,
                  FTC_MruNode   node );

  FT_LOCAL( void )
  FTC_MruNode_Remove( FTC_MruNode  *plist,
                      FTC_MruNode   node );


  FTC_MruList;

  FTC_MruListClass;


  FTC_MruNode_CompareFunc;

  FTC_MruNode_InitFunc;

  FTC_MruNode_ResetFunc;

  FTC_MruNode_DoneFunc;


  FTC_MruListClassRec;


  FTC_MruListRec;


  FT_LOCAL( void )
  FTC_MruList_Init( FTC_MruList       list,
                    FTC_MruListClass  clazz,
                    FT_UInt           max_nodes,
                    FT_Pointer        data,
                    FT_Memory         memory );

  FT_LOCAL( void )
  FTC_MruList_Reset( FTC_MruList  list );


  FT_LOCAL( void )
  FTC_MruList_Done( FTC_MruList  list );


  FT_LOCAL( FT_Error )
  FTC_MruList_New( FTC_MruList   list,
                   FT_Pointer    key,
                   FTC_MruNode  *anode );

  FT_LOCAL( void )
  FTC_MruList_Remove( FTC_MruList  list,
                      FTC_MruNode  node );

  FT_LOCAL( void )
  FTC_MruList_RemoveSelection( FTC_MruList              list,
                               FTC_MruNode_CompareFunc  selection,
                               FT_Pointer               key );


#ifdef FTC_INLINE

#define FTC_MRULIST_LOOKUP_CMP( list, key, compare, node, error )

#define FTC_MRULIST_LOOKUP( list, key, node, error )

#else  /* !FTC_INLINE */

  FT_LOCAL( FTC_MruNode )
  FTC_MruList_Find( FTC_MruList  list,
                    FT_Pointer   key );

  FT_LOCAL( FT_Error )
  FTC_MruList_Lookup( FTC_MruList   list,
                      FT_Pointer    key,
                      FTC_MruNode  *pnode );

#define FTC_MRULIST_LOOKUP

#endif /* !FTC_INLINE */


#define FTC_MRULIST_LOOP( list, node )


#define FTC_MRULIST_LOOP_END()

 /* */

FT_END_HEADER


#endif /* FTCMRU_H_ */


/* END */