1 /***************************************************************************/ |
1 /**************************************************************************** |
2 /* */ |
2 * |
3 /* ftutil.c */ |
3 * ftutil.c |
4 /* */ |
4 * |
5 /* FreeType utility file for memory and list management (body). */ |
5 * FreeType utility file for memory and list management (body). |
6 /* */ |
6 * |
7 /* Copyright 2002-2018 by */ |
7 * Copyright (C) 2002-2019 by |
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
8 * David Turner, Robert Wilhelm, and Werner Lemberg. |
9 /* */ |
9 * |
10 /* This file is part of the FreeType project, and may only be used, */ |
10 * This file is part of the FreeType project, and may only be used, |
11 /* modified, and distributed under the terms of the FreeType project */ |
11 * modified, and distributed under the terms of the FreeType project |
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ |
12 * license, LICENSE.TXT. By continuing to use, modify, or distribute |
13 /* this file you indicate that you have read the license and */ |
13 * this file you indicate that you have read the license and |
14 /* understand and accept it fully. */ |
14 * understand and accept it fully. |
15 /* */ |
15 * |
16 /***************************************************************************/ |
16 */ |
17 |
17 |
18 |
18 |
19 #include <ft2build.h> |
19 #include <ft2build.h> |
20 #include FT_INTERNAL_DEBUG_H |
20 #include FT_INTERNAL_DEBUG_H |
21 #include FT_INTERNAL_MEMORY_H |
21 #include FT_INTERNAL_MEMORY_H |
22 #include FT_INTERNAL_OBJECTS_H |
22 #include FT_INTERNAL_OBJECTS_H |
23 #include FT_LIST_H |
23 #include FT_LIST_H |
24 |
24 |
25 |
25 |
26 /*************************************************************************/ |
26 /************************************************************************** |
27 /* */ |
27 * |
28 /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ |
28 * The macro FT_COMPONENT is used in trace mode. It is an implicit |
29 /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ |
29 * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log |
30 /* messages during execution. */ |
30 * messages during execution. |
31 /* */ |
31 */ |
32 #undef FT_COMPONENT |
32 #undef FT_COMPONENT |
33 #define FT_COMPONENT trace_memory |
33 #define FT_COMPONENT memory |
34 |
34 |
35 |
35 |
36 /*************************************************************************/ |
36 /*************************************************************************/ |
37 /*************************************************************************/ |
37 /*************************************************************************/ |
38 /*************************************************************************/ |
38 /*************************************************************************/ |
99 FT_Error error = FT_Err_Ok; |
99 FT_Error error = FT_Err_Ok; |
100 |
100 |
101 |
101 |
102 block = ft_mem_qrealloc( memory, item_size, |
102 block = ft_mem_qrealloc( memory, item_size, |
103 cur_count, new_count, block, &error ); |
103 cur_count, new_count, block, &error ); |
104 if ( !error && new_count > cur_count ) |
104 if ( !error && block && new_count > cur_count ) |
105 FT_MEM_ZERO( (char*)block + cur_count * item_size, |
105 FT_MEM_ZERO( (char*)block + cur_count * item_size, |
106 ( new_count - cur_count ) * item_size ); |
106 ( new_count - cur_count ) * item_size ); |
107 |
107 |
108 *p_error = error; |
108 *p_error = error; |
109 return block; |
109 return block; |
234 /*************************************************************************/ |
234 /*************************************************************************/ |
235 /*************************************************************************/ |
235 /*************************************************************************/ |
236 /*************************************************************************/ |
236 /*************************************************************************/ |
237 |
237 |
238 #undef FT_COMPONENT |
238 #undef FT_COMPONENT |
239 #define FT_COMPONENT trace_list |
239 #define FT_COMPONENT list |
240 |
240 |
241 /* documentation is in ftlist.h */ |
241 /* documentation is in ftlist.h */ |
242 |
242 |
243 FT_EXPORT_DEF( FT_ListNode ) |
243 FT_EXPORT_DEF( FT_ListNode ) |
244 FT_List_Find( FT_List list, |
244 FT_List_Find( FT_List list, |