ReactOS 0.4.15-dev-7907-g95bf896
ftutil.c File Reference
#include <ft2build.h>
Include dependency graph for ftutil.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define FT_COMPONENT   trace_memory
 
#define FT_COMPONENT   trace_list
 

Functions

 ft_mem_alloc (FT_Memory memory, FT_Long size, FT_Error *p_error)
 
 ft_mem_qalloc (FT_Memory memory, FT_Long size, FT_Error *p_error)
 
 ft_mem_realloc (FT_Memory memory, FT_Long item_size, FT_Long cur_count, FT_Long new_count, void *block, FT_Error *p_error)
 
 ft_mem_qrealloc (FT_Memory memory, FT_Long item_size, FT_Long cur_count, FT_Long new_count, void *block, FT_Error *p_error)
 
 ft_mem_free (FT_Memory memory, const void *P)
 
 ft_mem_dup (FT_Memory memory, const void *address, FT_ULong size, FT_Error *p_error)
 
 ft_mem_strdup (FT_Memory memory, const char *str, FT_Error *p_error)
 
 ft_mem_strcpyn (char *dst, const char *src, FT_ULong size)
 
 FT_List_Find (FT_List list, void *data)
 
 FT_List_Add (FT_List list, FT_ListNode node)
 
 FT_List_Insert (FT_List list, FT_ListNode node)
 
 FT_List_Remove (FT_List list, FT_ListNode node)
 
 FT_List_Up (FT_List list, FT_ListNode node)
 
 FT_List_Iterate (FT_List list, FT_List_Iterator iterator, void *user)
 
 FT_List_Finalize (FT_List list, FT_List_Destructor destroy, FT_Memory memory, void *user)
 

Macro Definition Documentation

◆ FT_COMPONENT [1/2]

#define FT_COMPONENT   trace_memory

Definition at line 239 of file ftutil.c.

◆ FT_COMPONENT [2/2]

#define FT_COMPONENT   trace_list

Definition at line 239 of file ftutil.c.

Function Documentation

◆ FT_List_Add()

FT_List_Add ( FT_List  list,
FT_ListNode  node 
)

Definition at line 269 of file ftutil.c.

271 {
273
274
275 if ( !list || !node )
276 return;
277
278 before = list->tail;
279
280 node->next = NULL;
281 node->prev = before;
282
283 if ( before )
284 before->next = node;
285 else
286 list->head = node;
287
288 list->tail = node;
289 }
Definition: list.h:37
#define NULL
Definition: types.h:112
__inline int before(__u32 seq1, __u32 seq2)
Definition: tcpcore.h:2390
Definition: dlist.c:348
void * next
Definition: dlist.c:360

Referenced by ft_add_renderer(), FT_New_Size(), ft_open_face_internal(), and load_truetype_glyph().

◆ FT_List_Finalize()

FT_List_Finalize ( FT_List  list,
FT_List_Destructor  destroy,
FT_Memory  memory,
void user 
)

Definition at line 413 of file ftutil.c.

417 {
419
420
421 if ( !list || !memory )
422 return;
423
424 cur = list->head;
425 while ( cur )
426 {
427 FT_ListNode next = cur->next;
428 void* data = cur->data;
429
430
431 if ( destroy )
432 destroy( memory, data, user );
433
434 FT_FREE( cur );
435 cur = next;
436 }
437
438 list->head = NULL;
439 list->tail = NULL;
440 }
void destroy(_Tp *__pointer)
Definition: _construct.h:278
void user(int argc, const char *argv[])
Definition: cmds.c:1350
#define FT_FREE(ptr)
Definition: ftmemory.h:329
FxCollectionEntry * cur
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static char memory[1024 *256]
Definition: process.c:116
static unsigned __int64 next
Definition: rand_nt.c:6

Referenced by Destroy_Driver(), destroy_face(), and tt_loader_done().

◆ FT_List_Find()

FT_List_Find ( FT_List  list,
void data 
)

Definition at line 244 of file ftutil.c.

246 {
248
249
250 if ( !list )
251 return NULL;
252
253 cur = list->head;
254 while ( cur )
255 {
256 if ( cur->data == data )
257 return cur;
258
259 cur = cur->next;
260 }
261
262 return NULL;
263 }

Referenced by FT_Done_Face(), FT_Done_Size(), ft_remove_renderer(), FT_Set_Renderer(), load_truetype_glyph(), and T42_Size_Done().

◆ FT_List_Insert()

FT_List_Insert ( FT_List  list,
FT_ListNode  node 
)

Definition at line 295 of file ftutil.c.

297 {
299
300
301 if ( !list || !node )
302 return;
303
304 after = list->head;
305
306 node->next = after;
307 node->prev = NULL;
308
309 if ( !after )
310 list->tail = node;
311 else
312 after->prev = node;
313
314 list->head = node;
315 }
__inline int after(__u32 seq1, __u32 seq2)
Definition: tcpcore.h:2395

◆ FT_List_Iterate()

FT_List_Iterate ( FT_List  list,
FT_List_Iterator  iterator,
void user 
)

Definition at line 381 of file ftutil.c.

384 {
387
388
389 if ( !list || !iterator )
390 return FT_THROW( Invalid_Argument );
391
392 cur = list->head;
393
394 while ( cur )
395 {
396 FT_ListNode next = cur->next;
397
398
399 error = iterator( cur, user );
400 if ( error )
401 break;
402
403 cur = next;
404 }
405
406 return error;
407 }
return FT_Err_Ok
Definition: ftbbox.c:511
#define FT_THROW(e)
Definition: ftdebug.h:213
int FT_Error
Definition: fttypes.h:300
#define error(str)
Definition: mkdosfs.c:1605

◆ FT_List_Remove()

FT_List_Remove ( FT_List  list,
FT_ListNode  node 
)

Definition at line 321 of file ftutil.c.

323 {
325
326
327 if ( !list || !node )
328 return;
329
330 before = node->prev;
331 after = node->next;
332
333 if ( before )
334 before->next = after;
335 else
336 list->head = after;
337
338 if ( after )
339 after->prev = before;
340 else
341 list->tail = before;
342 }

Referenced by FT_Done_Face(), FT_Done_Size(), and ft_remove_renderer().

◆ FT_List_Up()

FT_List_Up ( FT_List  list,
FT_ListNode  node 
)

Definition at line 348 of file ftutil.c.

350 {
352
353
354 if ( !list || !node )
355 return;
356
357 before = node->prev;
358 after = node->next;
359
360 /* check whether we are already on top of the list */
361 if ( !before )
362 return;
363
364 before->next = after;
365
366 if ( after )
367 after->prev = before;
368 else
369 list->tail = before;
370
371 node->prev = NULL;
372 node->next = list->head;
373 list->head->prev = node;
374 list->head = node;
375 }
struct list * prev
Definition: list.h:39

Referenced by FT_Set_Renderer().

◆ ft_mem_alloc()

ft_mem_alloc ( FT_Memory  memory,
FT_Long  size,
FT_Error p_error 
)

Definition at line 50 of file ftutil.c.

53 {
56
57 if ( !error && size > 0 )
59
60 *p_error = error;
61 return block;
62 }
#define FT_MEM_ZERO(dest, count)
Definition: ftmemory.h:235
ft_mem_qalloc(FT_Memory memory, FT_Long size, FT_Error *p_error)
Definition: ftutil.c:66
GLsizeiptr size
Definition: glext.h:5919
static unsigned int block
Definition: xmlmemory.c:101

◆ ft_mem_dup()

ft_mem_dup ( FT_Memory  memory,
const void address,
FT_ULong  size,
FT_Error p_error 
)

Definition at line 179 of file ftutil.c.

183 {
186
187
188 if ( !error && address )
189 ft_memcpy( p, address, size );
190
191 *p_error = error;
192 return p;
193 }
#define ft_memcpy
Definition: ftstdlib.h:82
signed long FT_Long
Definition: fttypes.h:242
GLuint address
Definition: glext.h:9393
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by ft_mem_strdup().

◆ ft_mem_free()

ft_mem_free ( FT_Memory  memory,
const void P 
)

Definition at line 170 of file ftutil.c.

172 {
173 if ( P )
174 memory->free( memory, (void*)P );
175 }
#define P(row, col)

Referenced by ft_mem_qrealloc(), FT_Stream_ExitFrame(), and FT_Stream_ReleaseFrame().

◆ ft_mem_qalloc()

ft_mem_qalloc ( FT_Memory  memory,
FT_Long  size,
FT_Error p_error 
)

Definition at line 66 of file ftutil.c.

69 {
72
73
74 if ( size > 0 )
75 {
76 block = memory->alloc( memory, size );
77 if ( !block )
78 error = FT_THROW( Out_Of_Memory );
79 }
80 else if ( size < 0 )
81 {
82 /* may help catch/prevent security issues */
83 error = FT_THROW( Invalid_Argument );
84 }
85
86 *p_error = error;
87 return block;
88 }

Referenced by ft_mem_alloc(), ft_mem_dup(), and FT_Stream_EnterFrame().

◆ ft_mem_qrealloc()

ft_mem_qrealloc ( FT_Memory  memory,
FT_Long  item_size,
FT_Long  cur_count,
FT_Long  new_count,
void block,
FT_Error p_error 
)

Definition at line 114 of file ftutil.c.

120 {
122
123
124 /* Note that we now accept `item_size == 0' as a valid parameter, in
125 * order to cover very weird cases where an ALLOC_MULT macro would be
126 * called.
127 */
128 if ( cur_count < 0 || new_count < 0 || item_size < 0 )
129 {
130 /* may help catch/prevent nasty security issues */
131 error = FT_THROW( Invalid_Argument );
132 }
133 else if ( new_count == 0 || item_size == 0 )
134 {
136 block = NULL;
137 }
138 else if ( new_count > FT_INT_MAX / item_size )
139 {
140 error = FT_THROW( Array_Too_Large );
141 }
142 else if ( cur_count == 0 )
143 {
144 FT_ASSERT( !block );
145
146 block = memory->alloc( memory, new_count * item_size );
147 if ( block == NULL )
148 error = FT_THROW( Out_Of_Memory );
149 }
150 else
151 {
153 FT_Long cur_size = cur_count * item_size;
154 FT_Long new_size = new_count * item_size;
155
156
157 block2 = memory->realloc( memory, cur_size, new_size, block );
158 if ( !block2 )
159 error = FT_THROW( Out_Of_Memory );
160 else
161 block = block2;
162 }
163
164 *p_error = error;
165 return block;
166 }
#define FT_ASSERT(condition)
Definition: ftdebug.h:211
#define FT_INT_MAX
Definition: ftstdlib.h:63
ft_mem_free(FT_Memory memory, const void *P)
Definition: ftutil.c:170
static const struct metadata_block block2[]
Definition: metadata.c:2838

Referenced by ft_mem_realloc().

◆ ft_mem_realloc()

ft_mem_realloc ( FT_Memory  memory,
FT_Long  item_size,
FT_Long  cur_count,
FT_Long  new_count,
void block,
FT_Error p_error 
)

Definition at line 92 of file ftutil.c.

98 {
100
101
102 block = ft_mem_qrealloc( memory, item_size,
103 cur_count, new_count, block, &error );
104 if ( !error && new_count > cur_count )
105 FT_MEM_ZERO( (char*)block + cur_count * item_size,
106 ( new_count - cur_count ) * item_size );
107
108 *p_error = error;
109 return block;
110 }
ft_mem_qrealloc(FT_Memory memory, FT_Long item_size, FT_Long cur_count, FT_Long new_count, void *block, FT_Error *p_error)
Definition: ftutil.c:114

◆ ft_mem_strcpyn()

ft_mem_strcpyn ( char dst,
const char src,
FT_ULong  size 
)

Definition at line 210 of file ftutil.c.

213 {
214 while ( size > 1 && *src != 0 )
215 {
216 *dst++ = *src++;
217 size--;
218 }
219
220 *dst = 0; /* always zero-terminate */
221
222 return *src != 0;
223 }
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

◆ ft_mem_strdup()

ft_mem_strdup ( FT_Memory  memory,
const char str,
FT_Error p_error 
)

Definition at line 197 of file ftutil.c.

200 {
202 : 0;
203
204
205 return ft_mem_dup( memory, str, len, p_error );
206 }
#define ft_strlen
Definition: ftstdlib.h:88
unsigned long FT_ULong
Definition: fttypes.h:253
ft_mem_dup(FT_Memory memory, const void *address, FT_ULong size, FT_Error *p_error)
Definition: ftutil.c:179
GLenum GLsizei len
Definition: glext.h:6722
const WCHAR * str