ReactOS 0.4.16-dev-2354-g16de117
ftcmru.c File Reference
#include <freetype/ftcache.h>
#include "ftcmru.h"
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/ftdebug.h>
#include "ftcerror.h"
Include dependency graph for ftcmru.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

 FTC_MruNode_Prepend (FTC_MruNode *plist, FTC_MruNode node)
 
 FTC_MruNode_Up (FTC_MruNode *plist, FTC_MruNode node)
 
 FTC_MruNode_Remove (FTC_MruNode *plist, FTC_MruNode node)
 
 FTC_MruList_Init (FTC_MruList list, FTC_MruListClass clazz, FT_UInt max_nodes, FT_Pointer data, FT_Memory memory)
 
 FTC_MruList_Reset (FTC_MruList list)
 
 FTC_MruList_Done (FTC_MruList list)
 
 FTC_MruList_New (FTC_MruList list, FT_Pointer key, FTC_MruNode *anode)
 
 FTC_MruList_Remove (FTC_MruList list, FTC_MruNode node)
 
 FTC_MruList_RemoveSelection (FTC_MruList list, FTC_MruNode_CompareFunc selection, FT_Pointer key)
 

Function Documentation

◆ FTC_MruList_Done()

FTC_MruList_Done ( FTC_MruList  list)

Definition at line 194 of file ftcmru.c.

195 {
197 }
Definition: list.h:37
FTC_MruList_Reset(FTC_MruList list)
Definition: ftcmru.c:184

Referenced by ftc_gcache_done(), and FTC_Manager_Done().

◆ FTC_MruList_Init()

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

Definition at line 168 of file ftcmru.c.

173 {
174 list->num_nodes = 0;
175 list->max_nodes = max_nodes;
176 list->nodes = NULL;
177 list->clazz = *clazz;
178 list->data = data;
179 list->memory = memory;
180 }
#define NULL
Definition: types.h:112
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static char memory[1024 *256]
Definition: process.c:122

Referenced by ftc_gcache_init(), and FTC_Manager_New().

◆ FTC_MruList_New()

FTC_MruList_New ( FTC_MruList  list,
FT_Pointer  key,
FTC_MruNode anode 
)

Definition at line 235 of file ftcmru.c.

238 {
241 FT_Memory memory = list->memory;
242
243
244 if ( list->num_nodes >= list->max_nodes && list->max_nodes > 0 )
245 {
246 node = list->nodes->prev;
247
248 FT_ASSERT( node );
249
250 if ( list->clazz.node_reset )
251 {
252 FTC_MruNode_Up( &list->nodes, node );
253
254 error = list->clazz.node_reset( node, key, list->data );
255 if ( !error )
256 goto Exit;
257 }
258
259 FTC_MruNode_Remove( &list->nodes, node );
260 list->num_nodes--;
261
262 if ( list->clazz.node_done )
263 list->clazz.node_done( node, list->data );
264 }
265 else if ( FT_ALLOC( node, list->clazz.node_size ) )
266 goto Exit;
267
268 error = list->clazz.node_init( node, key, list->data );
269 if ( error )
270 goto Fail;
271
272 FTC_MruNode_Prepend( &list->nodes, node );
273 list->num_nodes++;
274
275 Exit:
276 *anode = node;
277 return error;
278
279 Fail:
280 if ( list->clazz.node_done )
281 list->clazz.node_done( node, list->data );
282
283 FT_FREE( node );
284 goto Exit;
285 }
struct list * prev
Definition: list.h:39
int Fail
Definition: ehthrow.cxx:24
FTC_MruNode_Up(FTC_MruNode *plist, FTC_MruNode node)
Definition: ftcmru.c:72
FTC_MruNode_Prepend(FTC_MruNode *plist, FTC_MruNode node)
Definition: ftcmru.c:28
FTC_MruNode_Remove(FTC_MruNode *plist, FTC_MruNode node)
Definition: ftcmru.c:121
typedefFT_BEGIN_HEADER struct FTC_MruNodeRec_ * FTC_MruNode
Definition: ftcmru.h:61
#define FT_ASSERT(condition)
Definition: ftdebug.h:241
#define FT_ALLOC(ptr, size)
Definition: ftmemory.h:311
#define FT_FREE(ptr)
Definition: ftmemory.h:337
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:64
int FT_Error
Definition: fttypes.h:299
#define error(str)
Definition: mkdosfs.c:1605
static void Exit(void)
Definition: sock.c:1330
Definition: copy.c:22
Definition: dlist.c:348

◆ FTC_MruList_Remove()

FTC_MruList_Remove ( FTC_MruList  list,
FTC_MruNode  node 
)

Definition at line 307 of file ftcmru.c.

309 {
310 FTC_MruNode_Remove( &list->nodes, node );
311 list->num_nodes--;
312
313 {
314 FT_Memory memory = list->memory;
315
316
317 if ( list->clazz.node_done )
318 list->clazz.node_done( node, list->data );
319
320 FT_FREE( node );
321 }
322 }

Referenced by FTC_MruList_RemoveSelection(), and FTC_MruList_Reset().

◆ FTC_MruList_RemoveSelection()

FTC_MruList_RemoveSelection ( FTC_MruList  list,
FTC_MruNode_CompareFunc  selection,
FT_Pointer  key 
)

Definition at line 326 of file ftcmru.c.

329 {
331
332
333 first = list->nodes;
334 while ( first && ( !selection || selection( first, key ) ) )
335 {
337 first = list->nodes;
338 }
339
340 if ( first )
341 {
342 node = first->next;
343 while ( node != first )
344 {
345 next = node->next;
346
347 if ( selection( node, key ) )
349
350 node = next;
351 }
352 }
353 }
int selection
Definition: ctm.c:92
FTC_MruList_Remove(FTC_MruList list, FTC_MruNode node)
Definition: ftcmru.c:307
const GLint * first
Definition: glext.h:5794
static unsigned __int64 next
Definition: rand_nt.c:6
void * next
Definition: dlist.c:360

Referenced by ftc_face_node_done(), and FTC_Manager_RemoveFaceID().

◆ FTC_MruList_Reset()

FTC_MruList_Reset ( FTC_MruList  list)

Definition at line 184 of file ftcmru.c.

185 {
186 while ( list->nodes )
187 FTC_MruList_Remove( list, list->nodes );
188
189 FT_ASSERT( list->num_nodes == 0 );
190 }

Referenced by FTC_Manager_Reset(), and FTC_MruList_Done().

◆ FTC_MruNode_Prepend()

FTC_MruNode_Prepend ( FTC_MruNode plist,
FTC_MruNode  node 
)

Definition at line 28 of file ftcmru.c.

30 {
32
33
34 if ( first )
35 {
36 FTC_MruNode last = first->prev;
37
38
39#ifdef FT_DEBUG_ERROR
40 {
41 FTC_MruNode cnode = first;
42
43
44 do
45 {
46 if ( cnode == node )
47 {
48 fprintf( stderr, "FTC_MruNode_Prepend: invalid action\n" );
49 exit( 2 );
50 }
51 cnode = cnode->next;
52
53 } while ( cnode != first );
54 }
55#endif
56
57 first->prev = node;
58 last->next = node;
59 node->next = first;
60 node->prev = last;
61 }
62 else
63 {
64 node->next = node;
65 node->prev = node;
66 }
67 *plist = node;
68 }
int WINAPIV fprintf(FILE *file, const char *format,...)
Definition: file.c:5549
#define stderr
static UINT UINT last
Definition: font.c:45
static Parse plist[]
Definition: dwarfinfo.c:339
#define exit(n)
Definition: config.h:202

Referenced by FTC_MruList_New(), and ftc_node_mru_link().

◆ FTC_MruNode_Remove()

FTC_MruNode_Remove ( FTC_MruNode plist,
FTC_MruNode  node 
)

Definition at line 121 of file ftcmru.c.

123 {
125 FTC_MruNode prev, next;
126
127
128 FT_ASSERT( first );
129
130#ifdef FT_DEBUG_ERROR
131 {
132 FTC_MruNode cnode = first;
133
134
135 do
136 {
137 if ( cnode == node )
138 goto Ok;
139 cnode = cnode->next;
140
141 } while ( cnode != first );
142
143 fprintf( stderr, "FTC_MruNode_Remove: invalid action\n" );
144 exit( 2 );
145 Ok:
146 }
147#endif
148
149 prev = node->prev;
150 next = node->next;
151
152 prev->next = next;
153 next->prev = prev;
154
155 if ( node == next )
156 {
157 FT_ASSERT( first == node );
158 FT_ASSERT( prev == node );
159
160 *plist = NULL;
161 }
162 else if ( node == first )
163 *plist = next;
164 }
@ Ok
Definition: gdiplustypes.h:26

Referenced by FTC_MruList_New(), FTC_MruList_Remove(), and ftc_node_mru_unlink().

◆ FTC_MruNode_Up()

FTC_MruNode_Up ( FTC_MruNode plist,
FTC_MruNode  node 
)

Definition at line 72 of file ftcmru.c.

74 {
76
77
79
80 if ( first != node )
81 {
82 FTC_MruNode prev, next, last;
83
84
85#ifdef FT_DEBUG_ERROR
86 {
87 FTC_MruNode cnode = first;
88 do
89 {
90 if ( cnode == node )
91 goto Ok;
92 cnode = cnode->next;
93
94 } while ( cnode != first );
95
96 fprintf( stderr, "FTC_MruNode_Up: invalid action\n" );
97 exit( 2 );
98 Ok:
99 }
100#endif
101 prev = node->prev;
102 next = node->next;
103
104 prev->next = next;
105 next->prev = prev;
106
107 last = first->prev;
108
109 last->next = node;
110 first->prev = node;
111
112 node->next = first;
113 node->prev = last;
114
115 *plist = node;
116 }
117 }

Referenced by FTC_MruList_New().