ReactOS 0.4.16-dev-2354-g16de117
ftutil.c File Reference
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   memory
 
#define FT_COMPONENT   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   memory

Definition at line 238 of file ftutil.c.

◆ FT_COMPONENT [2/2]

#define FT_COMPONENT   list

Definition at line 238 of file ftutil.c.

Function Documentation

◆ FT_List_Add()

FT_List_Add ( FT_List  list,
FT_ListNode  node 
)

Definition at line 268 of file ftutil.c.

270 {
272
273
274 if ( !list || !node )
275 return;
276
277 before = list->tail;
278
279 node->next = NULL;
280 node->prev = before;
281
282 if ( before )
283 before->next = node;
284 else
285 list->head = node;
286
287 list->tail = node;
288 }
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 cff_parser_run(), 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 412 of file ftutil.c.

416 {
418
419
420 if ( !list || !memory )
421 return;
422
423 cur = list->head;
424 while ( cur )
425 {
426 FT_ListNode next = cur->next;
427 void* data = cur->data;
428
429
430 if ( destroy )
431 destroy( memory, data, user );
432
433 FT_FREE( cur );
434 cur = next;
435 }
436
437 list->head = NULL;
438 list->tail = NULL;
439 }
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:337
FxCollectionEntry * cur
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static char memory[1024 *256]
Definition: process.c:122
static unsigned __int64 next
Definition: rand_nt.c:6

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

◆ FT_List_Find()

FT_List_Find ( FT_List  list,
void data 
)

Definition at line 243 of file ftutil.c.

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

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 294 of file ftutil.c.

296 {
298
299
300 if ( !list || !node )
301 return;
302
303 after = list->head;
304
305 node->next = after;
306 node->prev = NULL;
307
308 if ( !after )
309 list->tail = node;
310 else
311 after->prev = node;
312
313 list->head = node;
314 }
__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 380 of file ftutil.c.

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

◆ FT_List_Remove()

FT_List_Remove ( FT_List  list,
FT_ListNode  node 
)

Definition at line 320 of file ftutil.c.

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

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 347 of file ftutil.c.

349 {
351
352
353 if ( !list || !node )
354 return;
355
356 before = node->prev;
357 after = node->next;
358
359 /* check whether we are already on top of the list */
360 if ( !before )
361 return;
362
363 before->next = after;
364
365 if ( after )
366 after->prev = before;
367 else
368 list->tail = before;
369
370 node->prev = NULL;
371 node->next = list->head;
372 list->head->prev = node;
373 list->head = node;
374 }
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 49 of file ftutil.c.

52 {
55
56 if ( !error && block && size > 0 )
58
59 *p_error = error;
60 return block;
61 }
#define FT_MEM_ZERO(dest, count)
Definition: ftmemory.h:244
ft_mem_qalloc(FT_Memory memory, FT_Long size, FT_Error *p_error)
Definition: ftutil.c:65
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 178 of file ftutil.c.

182 {
185
186
187 if ( !error && address && size > 0 )
188 ft_memcpy( p, address, size );
189
190 *p_error = error;
191 return p;
192 }
#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 169 of file ftutil.c.

171 {
172 if ( P )
173 memory->free( memory, (void*)P );
174 }
#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 65 of file ftutil.c.

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

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 113 of file ftutil.c.

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

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 91 of file ftutil.c.

97 {
99
100
101 block = ft_mem_qrealloc( memory, item_size,
102 cur_count, new_count, block, &error );
103 if ( !error && block && new_count > cur_count )
104 FT_MEM_ZERO( (char*)block + cur_count * item_size,
105 ( new_count - cur_count ) * item_size );
106
107 *p_error = error;
108 return block;
109 }
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:113

◆ ft_mem_strcpyn()

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

Definition at line 209 of file ftutil.c.

212 {
213 while ( size > 1 && *src != 0 )
214 {
215 *dst++ = *src++;
216 size--;
217 }
218
219 *dst = 0; /* always zero-terminate */
220
221 return *src != 0;
222 }
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 196 of file ftutil.c.

199 {
201 : 0;
202
203
204 return ft_mem_dup( memory, str, len, p_error );
205 }
#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:178
GLenum GLsizei len
Definition: glext.h:6722
const WCHAR * str