misc/libfreetype/src/cache/ftcmru.c
author dag10
Mon, 21 Jan 2013 00:30:18 -0500 (2013-01-21)
changeset 8415 02acf6b92f52
parent 5172 88f2e05288ba
permissions -rw-r--r--
Moved room name edit box from footer to top of page. Also shows room name when in slave mode. Temporarily increased HWForm's min height from 580 to 610.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5172
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     1
/***************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     2
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     3
/*  ftcmru.c                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     4
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     5
/*    FreeType MRU support (body).                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     6
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     7
/*  Copyright 2003, 2004, 2006, 2009 by                                    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     8
/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     9
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    10
/*  This file is part of the FreeType project, and may only be used,       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    11
/*  modified, and distributed under the terms of the FreeType project      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    12
/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    13
/*  this file you indicate that you have read the license and              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    14
/*  understand and accept it fully.                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    15
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    16
/***************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    17
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    18
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    19
#include <ft2build.h>
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    20
#include FT_CACHE_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    21
#include "ftcmru.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    22
#include FT_INTERNAL_OBJECTS_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    23
#include FT_INTERNAL_DEBUG_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    24
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    25
#include "ftcerror.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    26
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    27
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    28
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    29
  FTC_MruNode_Prepend( FTC_MruNode  *plist,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    30
                       FTC_MruNode   node )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    31
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    32
    FTC_MruNode  first = *plist;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    33
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    34
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    35
    if ( first )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    36
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    37
      FTC_MruNode  last = first->prev;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    38
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    39
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    40
#ifdef FT_DEBUG_ERROR
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    41
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    42
        FTC_MruNode  cnode = first;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    43
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    44
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    45
        do
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    46
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    47
          if ( cnode == node )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    48
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    49
            fprintf( stderr, "FTC_MruNode_Prepend: invalid action\n" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    50
            exit( 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    51
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    52
          cnode = cnode->next;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    53
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    54
        } while ( cnode != first );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    55
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    56
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    57
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
      first->prev = node;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    59
      last->next  = node;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    60
      node->next  = first;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    61
      node->prev  = last;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    62
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    63
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    64
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    65
      node->next = node;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    66
      node->prev = node;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    67
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    68
    *plist = node;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    69
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    70
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    71
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    72
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    73
  FTC_MruNode_Up( FTC_MruNode  *plist,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    74
                  FTC_MruNode   node )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    75
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    76
    FTC_MruNode  first = *plist;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    77
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    78
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    79
    FT_ASSERT( first != NULL );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    80
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    81
    if ( first != node )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    82
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    83
      FTC_MruNode  prev, next, last;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    84
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    85
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    86
#ifdef FT_DEBUG_ERROR
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    87
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    88
        FTC_MruNode  cnode = first;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    89
        do
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    90
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    91
          if ( cnode == node )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    92
            goto Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    93
          cnode = cnode->next;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    94
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    95
        } while ( cnode != first );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    96
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    97
        fprintf( stderr, "FTC_MruNode_Up: invalid action\n" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    98
        exit( 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    99
      Ok:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   100
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   101
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   102
      prev = node->prev;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   103
      next = node->next;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   104
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   105
      prev->next = next;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   106
      next->prev = prev;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   107
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   108
      last = first->prev;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   109
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   110
      last->next  = node;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   111
      first->prev = node;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   112
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   113
      node->next = first;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   114
      node->prev = last;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   115
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   116
      *plist = node;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   117
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   118
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   119
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   120
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   121
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   122
  FTC_MruNode_Remove( FTC_MruNode  *plist,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   123
                      FTC_MruNode   node )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   124
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   125
    FTC_MruNode  first = *plist;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   126
    FTC_MruNode  prev, next;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   127
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   128
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   129
    FT_ASSERT( first != NULL );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   130
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   131
#ifdef FT_DEBUG_ERROR
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   132
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   133
        FTC_MruNode  cnode = first;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   134
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   135
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   136
        do
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   137
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   138
          if ( cnode == node )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   139
            goto Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   140
          cnode = cnode->next;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   141
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   142
        } while ( cnode != first );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   143
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   144
        fprintf( stderr, "FTC_MruNode_Remove: invalid action\n" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   145
        exit( 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   146
      Ok:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   147
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   148
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   149
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   150
    prev = node->prev;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   151
    next = node->next;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   152
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   153
    prev->next = next;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   154
    next->prev = prev;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   155
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   156
    if ( node == next )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   157
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   158
      FT_ASSERT( first == node );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   159
      FT_ASSERT( prev  == node );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   160
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   161
      *plist = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   162
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   163
    else if ( node == first )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   164
        *plist = next;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   165
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   166
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   167
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   168
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   169
  FTC_MruList_Init( FTC_MruList       list,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   170
                    FTC_MruListClass  clazz,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   171
                    FT_UInt           max_nodes,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   172
                    FT_Pointer        data,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   173
                    FT_Memory         memory )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   174
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   175
    list->num_nodes = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   176
    list->max_nodes = max_nodes;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   177
    list->nodes     = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   178
    list->clazz     = *clazz;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   179
    list->data      = data;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   180
    list->memory    = memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   181
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   182
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   183
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   184
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   185
  FTC_MruList_Reset( FTC_MruList  list )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   186
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   187
    while ( list->nodes )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   188
      FTC_MruList_Remove( list, list->nodes );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   189
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   190
    FT_ASSERT( list->num_nodes == 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   191
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   192
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   193
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   194
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   195
  FTC_MruList_Done( FTC_MruList  list )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   196
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   197
    FTC_MruList_Reset( list );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   198
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   199
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   200
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   201
#ifndef FTC_INLINE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   202
  FT_LOCAL_DEF( FTC_MruNode )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   203
  FTC_MruList_Find( FTC_MruList  list,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   204
                    FT_Pointer   key )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   205
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   206
    FTC_MruNode_CompareFunc  compare = list->clazz.node_compare;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   207
    FTC_MruNode              first, node;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   208
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   209
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   210
    first = list->nodes;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   211
    node  = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   212
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   213
    if ( first )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   214
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   215
      node = first;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   216
      do
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   217
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   218
        if ( compare( node, key ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   219
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   220
          if ( node != first )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   221
            FTC_MruNode_Up( &list->nodes, node );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   222
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   223
          return node;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   224
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   225
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   226
        node = node->next;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   227
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   228
      } while ( node != first);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   229
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   230
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   231
    return NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   232
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   233
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   234
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   235
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   236
  FTC_MruList_New( FTC_MruList   list,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   237
                   FT_Pointer    key,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   238
                   FTC_MruNode  *anode )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   239
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   240
    FT_Error     error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   241
    FTC_MruNode  node;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   242
    FT_Memory    memory = list->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   243
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   244
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   245
    if ( list->num_nodes >= list->max_nodes && list->max_nodes > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   246
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   247
      node = list->nodes->prev;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   248
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   249
      FT_ASSERT( node );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   250
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   251
      if ( list->clazz.node_reset )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   252
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   253
        FTC_MruNode_Up( &list->nodes, node );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   254
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   255
        error = list->clazz.node_reset( node, key, list->data );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   256
        if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   257
          goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   258
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   259
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   260
      FTC_MruNode_Remove( &list->nodes, node );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   261
      list->num_nodes--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   262
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   263
      if ( list->clazz.node_done )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   264
        list->clazz.node_done( node, list->data );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   265
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   266
    else if ( FT_ALLOC( node, list->clazz.node_size ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   267
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   268
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   269
    error = list->clazz.node_init( node, key, list->data );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   270
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   271
      goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   272
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   273
      FTC_MruNode_Prepend( &list->nodes, node );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   274
      list->num_nodes++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   275
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   276
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   277
    *anode = node;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   278
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   279
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   280
  Fail:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   281
    if ( list->clazz.node_done )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   282
      list->clazz.node_done( node, list->data );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   283
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   284
    FT_FREE( node );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   285
    goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   286
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   287
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   288
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   289
#ifndef FTC_INLINE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   290
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   291
  FTC_MruList_Lookup( FTC_MruList   list,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   292
                      FT_Pointer    key,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   293
                      FTC_MruNode  *anode )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   294
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   295
    FTC_MruNode  node;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   296
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   297
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   298
    node = FTC_MruList_Find( list, key );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   299
    if ( node == NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   300
      return FTC_MruList_New( list, key, anode );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   301
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   302
    *anode = node;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   303
    return 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   304
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   305
#endif /* FTC_INLINE */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   306
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   307
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   308
  FTC_MruList_Remove( FTC_MruList  list,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   309
                      FTC_MruNode  node )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   310
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   311
    FTC_MruNode_Remove( &list->nodes, node );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   312
    list->num_nodes--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   313
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   314
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   315
      FT_Memory  memory = list->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   316
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   317
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   318
      if ( list->clazz.node_done )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   319
       list->clazz.node_done( node, list->data );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   320
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   321
      FT_FREE( node );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   322
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   323
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   324
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   325
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   326
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   327
  FTC_MruList_RemoveSelection( FTC_MruList              list,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   328
                               FTC_MruNode_CompareFunc  selection,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   329
                               FT_Pointer               key )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   330
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   331
    FTC_MruNode  first, node, next;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   332
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   333
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   334
    first = list->nodes;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   335
    while ( first && ( selection == NULL || selection( first, key ) ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   336
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   337
      FTC_MruList_Remove( list, first );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   338
      first = list->nodes;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   339
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   340
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   341
    if ( first )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   342
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   343
      node = first->next;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   344
      while ( node != first )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   345
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   346
        next = node->next;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   347
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   348
        if ( selection( node, key ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   349
          FTC_MruList_Remove( list, node );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   350
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   351
        node = next;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   352
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   353
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   354
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   355
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   356
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   357
/* END */