Lines 57-63
FT_BEGIN_HEADER
Link Here
|
57 |
/*************************************************************************/ |
57 |
/*************************************************************************/ |
58 |
|
58 |
|
59 |
|
59 |
|
60 |
#ifdef FT_STRICT_ALIASING |
60 |
/* C++ absolutely hates statements like p = (void*)anything; where 'p' is |
|
|
61 |
* a typed pointer. Since we don't have a typeof operator in standard C++, |
62 |
* we need some really ugly casts, like: |
63 |
*/ |
64 |
#ifdef __cplusplus |
65 |
# define FT_ASSIGNP(p,val) *((void**)&(p)) = (val) |
66 |
#else |
67 |
# define FT_ASSIGNP(p,val) (p) = (val) |
68 |
#endif |
69 |
|
70 |
|
71 |
|
72 |
#ifdef FT_DEBUG_MEMORY |
73 |
|
74 |
FT_BASE( const char* ) _ft_debug_file; |
75 |
FT_BASE( long ) _ft_debug_lineno; |
76 |
|
77 |
# define FT_DEBUG_INNER( exp ) ( _ft_debug_file = __FILE__, \ |
78 |
_ft_debug_lineno = __LINE__, \ |
79 |
(exp) ) |
80 |
|
81 |
# define FT_ASSIGNP_INNER( p, exp ) ( _ft_debug_file = __FILE__, \ |
82 |
_ft_debug_lineno = __LINE__, \ |
83 |
FT_ASSIGNP( p, exp ) ) |
84 |
|
85 |
#else /* !FT_DEBUG_MEMORY */ |
86 |
|
87 |
# define FT_DEBUG_INNER( exp ) (exp) |
88 |
# define FT_ASSIGNP_INNER( p, exp ) FT_ASSIGNP( p, exp ) |
89 |
|
90 |
#endif /* !FT_DEBUG_MEMORY */ |
61 |
|
91 |
|
62 |
|
92 |
|
63 |
/* |
93 |
/* |
Lines 78-92
FT_BEGIN_HEADER
Link Here
|
78 |
|
108 |
|
79 |
FT_BASE( FT_Pointer ) |
109 |
FT_BASE( FT_Pointer ) |
80 |
ft_mem_realloc( FT_Memory memory, |
110 |
ft_mem_realloc( FT_Memory memory, |
81 |
FT_Long current, |
111 |
FT_Long item_size, |
82 |
FT_Long size, |
112 |
FT_Long cur_count, |
|
|
113 |
FT_Long new_count, |
83 |
void* block, |
114 |
void* block, |
84 |
FT_Error *p_error ); |
115 |
FT_Error *p_error ); |
85 |
|
116 |
|
86 |
FT_BASE( FT_Pointer ) |
117 |
FT_BASE( FT_Pointer ) |
87 |
ft_mem_qrealloc( FT_Memory memory, |
118 |
ft_mem_qrealloc( FT_Memory memory, |
88 |
FT_Long current, |
119 |
FT_Long item_size, |
89 |
FT_Long size, |
120 |
FT_Long cur_count, |
|
|
121 |
FT_Long new_count, |
90 |
void* block, |
122 |
void* block, |
91 |
FT_Error *p_error ); |
123 |
FT_Error *p_error ); |
92 |
|
124 |
|
Lines 95-460
FT_BEGIN_HEADER
Link Here
|
95 |
const void* P ); |
127 |
const void* P ); |
96 |
|
128 |
|
97 |
|
129 |
|
98 |
#ifdef FT_DEBUG_MEMORY |
130 |
#define FT_MEM_ALLOC( ptr, size ) \ |
99 |
|
131 |
FT_ASSIGNP_INNER( ptr, ft_mem_alloc( memory, (size), &error ) ) |
100 |
|
|
|
101 |
FT_BASE( FT_Pointer ) |
102 |
ft_mem_alloc_debug( FT_Memory memory, |
103 |
FT_Long size, |
104 |
FT_Error *p_error, |
105 |
const char* file_name, |
106 |
FT_Long line_no ); |
107 |
|
108 |
FT_BASE( FT_Pointer ) |
109 |
ft_mem_qalloc_debug( FT_Memory memory, |
110 |
FT_Long size, |
111 |
FT_Error *p_error, |
112 |
const char* file_name, |
113 |
FT_Long line_no ); |
114 |
|
115 |
FT_BASE( FT_Pointer ) |
116 |
ft_mem_realloc_debug( FT_Memory memory, |
117 |
FT_Long current, |
118 |
FT_Long size, |
119 |
void* P, |
120 |
FT_Error *p_error, |
121 |
const char* file_name, |
122 |
FT_Long line_no ); |
123 |
|
124 |
FT_BASE( FT_Pointer ) |
125 |
ft_mem_qrealloc_debug( FT_Memory memory, |
126 |
FT_Long current, |
127 |
FT_Long size, |
128 |
void* P, |
129 |
FT_Error *p_error, |
130 |
const char* file_name, |
131 |
FT_Long line_no ); |
132 |
|
133 |
FT_BASE( void ) |
134 |
ft_mem_free_debug( FT_Memory memory, |
135 |
const void *P, |
136 |
const char* file_name, |
137 |
FT_Long line_no ); |
138 |
|
139 |
|
140 |
#define FT_MEM_ALLOC( _pointer_, _size_ ) \ |
141 |
(_pointer_) = ft_mem_alloc_debug( memory, _size_, &error, \ |
142 |
__FILE__, __LINE__ ) |
143 |
|
144 |
#define FT_MEM_REALLOC( _pointer_, _current_, _size_ ) \ |
145 |
(_pointer_) = ft_mem_realloc_debug( memory, _current_, _size_, \ |
146 |
(_pointer_), &error, \ |
147 |
__FILE__, __LINE__ ) |
148 |
|
149 |
#define FT_MEM_QALLOC( _pointer_, _size_ ) \ |
150 |
(_pointer_) = ft_mem_qalloc_debug( memory, _size_, &error, \ |
151 |
__FILE__, __LINE__ ) |
152 |
|
153 |
#define FT_MEM_QREALLOC( _pointer_, _current_, _size_ ) \ |
154 |
(_pointer_) = ft_mem_qrealloc_debug( memory, _current_, _size_, \ |
155 |
(_pointer_), &error, \ |
156 |
__FILE__, __LINE__ ) |
157 |
|
158 |
#define FT_MEM_FREE( _pointer_ ) \ |
159 |
FT_BEGIN_STMNT \ |
160 |
if ( _pointer_ ) \ |
161 |
{ \ |
162 |
ft_mem_free_debug( memory, (_pointer_), __FILE__, __LINE__ ); \ |
163 |
(_pointer_) = NULL; \ |
164 |
} \ |
165 |
FT_END_STMNT |
166 |
|
167 |
|
168 |
#else /* !FT_DEBUG_MEMORY */ |
169 |
|
170 |
|
132 |
|
171 |
#define FT_MEM_ALLOC( _pointer_, _size_ ) \ |
133 |
#define FT_MEM_FREE( ptr ) \ |
172 |
(_pointer_) = ft_mem_alloc( memory, _size_, &error ) |
134 |
FT_BEGIN_STMNT \ |
173 |
|
135 |
ft_mem_free( memory, (ptr) ); \ |
174 |
#define FT_MEM_FREE( _pointer_ ) \ |
136 |
(ptr) = NULL; \ |
175 |
FT_BEGIN_STMNT \ |
|
|
176 |
if ( (_pointer_) ) \ |
177 |
{ \ |
178 |
ft_mem_free( memory, (_pointer_) ); \ |
179 |
(_pointer_) = NULL; \ |
180 |
} \ |
181 |
FT_END_STMNT |
137 |
FT_END_STMNT |
182 |
|
138 |
|
183 |
#define FT_MEM_REALLOC( _pointer_, _current_, _size_ ) \ |
139 |
#define FT_MEM_NEW( ptr ) \ |
184 |
(_pointer_) = ft_mem_realloc( memory, _current_, _size_, \ |
140 |
FT_MEM_ALLOC( ptr, sizeof ( *(ptr) ) ) |
185 |
(_pointer_), &error ) |
|
|
186 |
|
187 |
#define FT_MEM_QALLOC( _pointer_, _size_ ) \ |
188 |
(_pointer_) = ft_mem_qalloc( memory, _size_, &error ) |
189 |
|
190 |
#define FT_MEM_QREALLOC( _pointer_, _current_, _size_ ) \ |
191 |
(_pointer_) = ft_mem_qrealloc( memory, _current_, _size_, \ |
192 |
(_pointer_), &error ) |
193 |
|
194 |
#endif /* !FT_DEBUG_MEMORY */ |
195 |
|
196 |
|
197 |
#define FT_MEM_SET_ERROR( cond ) ( (cond), error != 0 ) |
198 |
|
199 |
|
200 |
#else /* !FT_STRICT_ALIASING */ |
201 |
|
202 |
|
203 |
#ifdef FT_DEBUG_MEMORY |
204 |
|
205 |
|
206 |
FT_BASE( FT_Error ) |
207 |
ft_mem_alloc_debug( FT_Memory memory, |
208 |
FT_Long size, |
209 |
void* *P, |
210 |
const char* file_name, |
211 |
FT_Long line_no ); |
212 |
|
213 |
FT_BASE( FT_Error ) |
214 |
ft_mem_qalloc_debug( FT_Memory memory, |
215 |
FT_Long size, |
216 |
void* *P, |
217 |
const char* file_name, |
218 |
FT_Long line_no ); |
219 |
|
220 |
FT_BASE( FT_Error ) |
221 |
ft_mem_realloc_debug( FT_Memory memory, |
222 |
FT_Long current, |
223 |
FT_Long size, |
224 |
void* *P, |
225 |
const char* file_name, |
226 |
FT_Long line_no ); |
227 |
|
228 |
FT_BASE( FT_Error ) |
229 |
ft_mem_qrealloc_debug( FT_Memory memory, |
230 |
FT_Long current, |
231 |
FT_Long size, |
232 |
void* *P, |
233 |
const char* file_name, |
234 |
FT_Long line_no ); |
235 |
|
236 |
FT_BASE( void ) |
237 |
ft_mem_free_debug( FT_Memory memory, |
238 |
FT_Pointer block, |
239 |
const char* file_name, |
240 |
FT_Long line_no ); |
241 |
|
242 |
|
243 |
#endif /* FT_DEBUG_MEMORY */ |
244 |
|
245 |
|
246 |
/*************************************************************************/ |
247 |
/* */ |
248 |
/* <Function> */ |
249 |
/* ft_mem_alloc */ |
250 |
/* */ |
251 |
/* <Description> */ |
252 |
/* Allocates a new block of memory. The returned area is always */ |
253 |
/* zero-filled; this is a strong convention in many FreeType parts. */ |
254 |
/* */ |
255 |
/* <Input> */ |
256 |
/* memory :: A handle to a given `memory object' which handles */ |
257 |
/* allocation. */ |
258 |
/* */ |
259 |
/* size :: The size in bytes of the block to allocate. */ |
260 |
/* */ |
261 |
/* <Output> */ |
262 |
/* P :: A pointer to the fresh new block. It should be set to */ |
263 |
/* NULL if `size' is 0, or in case of error. */ |
264 |
/* */ |
265 |
/* <Return> */ |
266 |
/* FreeType error code. 0 means success. */ |
267 |
/* */ |
268 |
FT_BASE( FT_Error ) |
269 |
ft_mem_alloc( FT_Memory memory, |
270 |
FT_Long size, |
271 |
void* *P ); |
272 |
|
273 |
|
274 |
/*************************************************************************/ |
275 |
/* */ |
276 |
/* <Function> */ |
277 |
/* ft_mem_qalloc */ |
278 |
/* */ |
279 |
/* <Description> */ |
280 |
/* Allocates a new block of memory. The returned area is *not* */ |
281 |
/* zero-filled, making allocation quicker. */ |
282 |
/* */ |
283 |
/* <Input> */ |
284 |
/* memory :: A handle to a given `memory object' which handles */ |
285 |
/* allocation. */ |
286 |
/* */ |
287 |
/* size :: The size in bytes of the block to allocate. */ |
288 |
/* */ |
289 |
/* <Output> */ |
290 |
/* P :: A pointer to the fresh new block. It should be set to */ |
291 |
/* NULL if `size' is 0, or in case of error. */ |
292 |
/* */ |
293 |
/* <Return> */ |
294 |
/* FreeType error code. 0 means success. */ |
295 |
/* */ |
296 |
FT_BASE( FT_Error ) |
297 |
ft_mem_qalloc( FT_Memory memory, |
298 |
FT_Long size, |
299 |
void* *p ); |
300 |
|
301 |
|
302 |
/*************************************************************************/ |
303 |
/* */ |
304 |
/* <Function> */ |
305 |
/* ft_mem_realloc */ |
306 |
/* */ |
307 |
/* <Description> */ |
308 |
/* Reallocates a block of memory pointed to by `*P' to `Size' bytes */ |
309 |
/* from the heap, possibly changing `*P'. The returned area is */ |
310 |
/* zero-filled. */ |
311 |
/* */ |
312 |
/* <Input> */ |
313 |
/* memory :: A handle to a given `memory object' which handles */ |
314 |
/* reallocation. */ |
315 |
/* */ |
316 |
/* current :: The current block size in bytes. */ |
317 |
/* */ |
318 |
/* size :: The new block size in bytes. */ |
319 |
/* */ |
320 |
/* <InOut> */ |
321 |
/* P :: A pointer to the fresh new block. It should be set to */ |
322 |
/* NULL if `size' is 0, or in case of error. */ |
323 |
/* */ |
324 |
/* <Return> */ |
325 |
/* FreeType error code. 0 means success. */ |
326 |
/* */ |
327 |
/* <Note> */ |
328 |
/* All callers of ft_mem_realloc() _must_ provide the current block */ |
329 |
/* size as well as the new one. */ |
330 |
/* */ |
331 |
FT_BASE( FT_Error ) |
332 |
ft_mem_realloc( FT_Memory memory, |
333 |
FT_Long current, |
334 |
FT_Long size, |
335 |
void* *P ); |
336 |
|
337 |
|
338 |
/*************************************************************************/ |
339 |
/* */ |
340 |
/* <Function> */ |
341 |
/* ft_mem_qrealloc */ |
342 |
/* */ |
343 |
/* <Description> */ |
344 |
/* Reallocates a block of memory pointed to by `*P' to `Size' bytes */ |
345 |
/* from the heap, possibly changing `*P'. The returned area is *not* */ |
346 |
/* zero-filled, making reallocation quicker. */ |
347 |
/* */ |
348 |
/* <Input> */ |
349 |
/* memory :: A handle to a given `memory object' which handles */ |
350 |
/* reallocation. */ |
351 |
/* */ |
352 |
/* current :: The current block size in bytes. */ |
353 |
/* */ |
354 |
/* size :: The new block size in bytes. */ |
355 |
/* */ |
356 |
/* <InOut> */ |
357 |
/* P :: A pointer to the fresh new block. It should be set to */ |
358 |
/* NULL if `size' is 0, or in case of error. */ |
359 |
/* */ |
360 |
/* <Return> */ |
361 |
/* FreeType error code. 0 means success. */ |
362 |
/* */ |
363 |
/* <Note> */ |
364 |
/* All callers of ft_mem_realloc() _must_ provide the current block */ |
365 |
/* size as well as the new one. */ |
366 |
/* */ |
367 |
FT_BASE( FT_Error ) |
368 |
ft_mem_qrealloc( FT_Memory memory, |
369 |
FT_Long current, |
370 |
FT_Long size, |
371 |
void* *p ); |
372 |
|
373 |
|
374 |
/*************************************************************************/ |
375 |
/* */ |
376 |
/* <Function> */ |
377 |
/* ft_mem_free */ |
378 |
/* */ |
379 |
/* <Description> */ |
380 |
/* Releases a given block of memory allocated through ft_mem_alloc(). */ |
381 |
/* */ |
382 |
/* <Input> */ |
383 |
/* memory :: A handle to a given `memory object' which handles */ |
384 |
/* memory deallocation */ |
385 |
/* */ |
386 |
/* P :: This is the _address_ of a _pointer_ which points to the */ |
387 |
/* allocated block. It is always set to NULL on exit. */ |
388 |
/* */ |
389 |
/* <Note> */ |
390 |
/* If P or *P is NULL, this function should return successfully. */ |
391 |
/* This is a strong convention within all of FreeType and its */ |
392 |
/* drivers. */ |
393 |
/* */ |
394 |
FT_BASE( void ) |
395 |
ft_mem_free( FT_Memory memory, |
396 |
void* *P ); |
397 |
|
398 |
|
399 |
#ifdef FT_DEBUG_MEMORY |
400 |
|
401 |
|
402 |
#define FT_MEM_ALLOC( _pointer_, _size_ ) \ |
403 |
ft_mem_alloc_debug( memory, _size_, \ |
404 |
(void**)(void*)&(_pointer_), \ |
405 |
__FILE__, __LINE__ ) |
406 |
|
407 |
#define FT_MEM_REALLOC( _pointer_, _current_, _size_ ) \ |
408 |
ft_mem_realloc_debug( memory, _current_, _size_, \ |
409 |
(void**)(void*)&(_pointer_), \ |
410 |
__FILE__, __LINE__ ) |
411 |
|
412 |
#define FT_MEM_QALLOC( _pointer_, _size_ ) \ |
413 |
ft_mem_qalloc_debug( memory, _size_, \ |
414 |
(void**)(void*)&(_pointer_), \ |
415 |
__FILE__, __LINE__ ) |
416 |
|
417 |
#define FT_MEM_QREALLOC( _pointer_, _current_, _size_ ) \ |
418 |
ft_mem_qrealloc_debug( memory, _current_, _size_, \ |
419 |
(void**)(void*)&(_pointer_), \ |
420 |
__FILE__, __LINE__ ) |
421 |
|
422 |
#define FT_MEM_FREE( _pointer_ ) \ |
423 |
ft_mem_free_debug( memory, (void**)(void*)&(_pointer_), \ |
424 |
__FILE__, __LINE__ ) |
425 |
|
426 |
|
427 |
#else /* !FT_DEBUG_MEMORY */ |
428 |
|
429 |
|
430 |
#define FT_MEM_ALLOC( _pointer_, _size_ ) \ |
431 |
ft_mem_alloc( memory, _size_, \ |
432 |
(void**)(void*)&(_pointer_) ) |
433 |
|
434 |
#define FT_MEM_FREE( _pointer_ ) \ |
435 |
ft_mem_free( memory, \ |
436 |
(void**)(void*)&(_pointer_) ) |
437 |
|
438 |
#define FT_MEM_REALLOC( _pointer_, _current_, _size_ ) \ |
439 |
ft_mem_realloc( memory, _current_, _size_, \ |
440 |
(void**)(void*)&(_pointer_) ) |
441 |
|
442 |
#define FT_MEM_QALLOC( _pointer_, _size_ ) \ |
443 |
ft_mem_qalloc( memory, _size_, \ |
444 |
(void**)(void*)&(_pointer_) ) |
445 |
|
446 |
#define FT_MEM_QREALLOC( _pointer_, _current_, _size_ ) \ |
447 |
ft_mem_qrealloc( memory, _current_, _size_, \ |
448 |
(void**)(void*)&(_pointer_) ) |
449 |
|
450 |
|
451 |
#endif /* !FT_DEBUG_MEMORY */ |
452 |
|
453 |
|
141 |
|
454 |
#define FT_MEM_SET_ERROR( cond ) ( ( error = (cond) ) != 0 ) |
142 |
#define FT_MEM_REALLOC( ptr, cursz, newsz ) \ |
|
|
143 |
FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, 1, \ |
144 |
(cursz), (newsz), \ |
145 |
(ptr), &error ) ) |
146 |
|
147 |
#define FT_MEM_QALLOC( ptr, size ) \ |
148 |
FT_ASSIGNP_INNER( ptr, ft_mem_qalloc( memory, (size), &error ) ) |
149 |
|
150 |
#define FT_MEM_QNEW( ptr ) \ |
151 |
FT_MEM_QALLOC( ptr, sizeof ( *(ptr) ) ) |
152 |
|
153 |
#define FT_MEM_QREALLOC( ptr, cursz, newsz ) \ |
154 |
FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, 1, \ |
155 |
(cursz), (newsz), \ |
156 |
(ptr), &error ) ) |
157 |
|
158 |
#define FT_MEM_QRENEW_ARRAY( ptr, cursz, newsz ) \ |
159 |
FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, sizeof ( *(ptr) ), \ |
160 |
(cursz), (newsz), \ |
161 |
(ptr), &error ) ) |
162 |
|
163 |
#define FT_MEM_ALLOC_MULT( ptr, count, item_size ) \ |
164 |
FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, (item_size), \ |
165 |
0, (count), \ |
166 |
NULL, &error ) ) |
167 |
|
168 |
#define FT_MEM_REALLOC_MULT( ptr, oldcnt, newcnt, itmsz ) \ |
169 |
FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, (itmsz), \ |
170 |
(oldcnt), (newcnt), \ |
171 |
(ptr), &error ) ) |
172 |
|
173 |
#define FT_MEM_QALLOC_MULT( ptr, count, item_size ) \ |
174 |
FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, (item_size), \ |
175 |
0, (count), \ |
176 |
NULL, &error ) ) |
177 |
|
178 |
#define FT_MEM_QREALLOC_MULT( ptr, oldcnt, newcnt, itmsz) \ |
179 |
FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, (itmsz), \ |
180 |
(oldcnt), (newcnt), \ |
181 |
(ptr), &error ) ) |
455 |
|
182 |
|
456 |
|
183 |
|
457 |
#endif /* !FT_STRICT_ALIASING */ |
184 |
#define FT_MEM_SET_ERROR( cond ) ( (cond), error != 0 ) |
458 |
|
185 |
|
459 |
|
186 |
|
460 |
#define FT_MEM_SET( dest, byte, count ) ft_memset( dest, byte, count ) |
187 |
#define FT_MEM_SET( dest, byte, count ) ft_memset( dest, byte, count ) |
Lines 494-584
FT_BEGIN_HEADER
Link Here
|
494 |
/* _typed_ in order to automatically compute array element sizes. */ |
222 |
/* _typed_ in order to automatically compute array element sizes. */ |
495 |
/* */ |
223 |
/* */ |
496 |
|
224 |
|
497 |
#define FT_MEM_NEW( _pointer_ ) \ |
225 |
#define FT_MEM_NEW_ARRAY( ptr, count ) \ |
498 |
FT_MEM_ALLOC( _pointer_, sizeof ( *(_pointer_) ) ) |
226 |
FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, sizeof ( *(ptr) ), \ |
499 |
|
227 |
0, (count), \ |
500 |
#define FT_MEM_NEW_ARRAY( _pointer_, _count_ ) \ |
228 |
NULL, &error ) ) |
501 |
FT_MEM_ALLOC( _pointer_, (_count_) * sizeof ( *(_pointer_) ) ) |
|
|
502 |
|
503 |
#define FT_MEM_RENEW_ARRAY( _pointer_, _old_, _new_ ) \ |
504 |
FT_MEM_REALLOC( _pointer_, (_old_) * sizeof ( *(_pointer_) ), \ |
505 |
(_new_) * sizeof ( *(_pointer_) ) ) |
506 |
|
507 |
#define FT_MEM_QNEW( _pointer_ ) \ |
508 |
FT_MEM_QALLOC( _pointer_, sizeof ( *(_pointer_) ) ) |
509 |
|
510 |
#define FT_MEM_QNEW_ARRAY( _pointer_, _count_ ) \ |
511 |
FT_MEM_QALLOC( _pointer_, (_count_) * sizeof ( *(_pointer_) ) ) |
512 |
|
513 |
#define FT_MEM_QRENEW_ARRAY( _pointer_, _old_, _new_ ) \ |
514 |
FT_MEM_QREALLOC( _pointer_, (_old_) * sizeof ( *(_pointer_) ), \ |
515 |
(_new_) * sizeof ( *(_pointer_) ) ) |
516 |
|
517 |
|
518 |
/*************************************************************************/ |
519 |
/* */ |
520 |
/* the following macros are obsolete but kept for compatibility reasons */ |
521 |
/* */ |
522 |
|
523 |
#define FT_MEM_ALLOC_ARRAY( _pointer_, _count_, _type_ ) \ |
524 |
FT_MEM_ALLOC( _pointer_, (_count_) * sizeof ( _type_ ) ) |
525 |
|
229 |
|
526 |
#define FT_MEM_REALLOC_ARRAY( _pointer_, _old_, _new_, _type_ ) \ |
230 |
#define FT_MEM_RENEW_ARRAY( ptr, cursz, newsz ) \ |
527 |
FT_MEM_REALLOC( _pointer_, (_old_) * sizeof ( _type ), \ |
231 |
FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, sizeof ( *(ptr) ), \ |
528 |
(_new_) * sizeof ( _type_ ) ) |
232 |
(cursz), (newsz), \ |
|
|
233 |
(ptr), &error ) ) |
529 |
|
234 |
|
|
|
235 |
#define FT_MEM_QNEW_ARRAY( ptr, count ) \ |
236 |
FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, sizeof ( *(ptr) ), \ |
237 |
0, (count), \ |
238 |
NULL, &error ) ) |
530 |
|
239 |
|
531 |
/*************************************************************************/ |
240 |
#define FT_MEM_QRENEW_ARRAY( ptr, cursz, newsz ) \ |
532 |
/* */ |
241 |
FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, sizeof ( *(ptr) ), \ |
533 |
/* The following macros are variants of their FT_MEM_XXXX equivalents; */ |
242 |
(cursz), (newsz), \ |
534 |
/* they are used to set an _implicit_ `error' variable and return TRUE */ |
243 |
(ptr), &error ) ) |
535 |
/* if an error occured (i.e., if `error != 0'). */ |
|
|
536 |
/* */ |
537 |
|
244 |
|
538 |
#define FT_ALLOC( _pointer_, _size_ ) \ |
|
|
539 |
FT_MEM_SET_ERROR( FT_MEM_ALLOC( _pointer_, _size_ ) ) |
540 |
|
245 |
|
541 |
#define FT_REALLOC( _pointer_, _current_, _size_ ) \ |
246 |
#define FT_ALLOC( ptr, size ) \ |
542 |
FT_MEM_SET_ERROR( FT_MEM_REALLOC( _pointer_, _current_, _size_ ) ) |
247 |
FT_MEM_SET_ERROR( FT_MEM_ALLOC( ptr, size ) ) |
543 |
|
248 |
|
544 |
#define FT_QALLOC( _pointer_, _size_ ) \ |
249 |
#define FT_REALLOC( ptr, cursz, newsz ) \ |
545 |
FT_MEM_SET_ERROR( FT_MEM_QALLOC( _pointer_, _size_ ) ) |
250 |
FT_MEM_SET_ERROR( FT_MEM_REALLOC( ptr, cursz, newsz ) ) |
546 |
|
251 |
|
547 |
#define FT_QREALLOC( _pointer_, _current_, _size_ ) \ |
252 |
#define FT_ALLOC_MULT( ptr, count, item_size ) \ |
548 |
FT_MEM_SET_ERROR( FT_MEM_QREALLOC( _pointer_, _current_, _size_ ) ) |
253 |
FT_MEM_SET_ERROR( FT_MEM_ALLOC_MULT( ptr, count, item_size ) ) |
549 |
|
254 |
|
|
|
255 |
#define FT_REALLOC_MULT( ptr, oldcnt, newcnt, itmsz ) \ |
256 |
FT_MEM_SET_ERROR( FT_MEM_REALLOC_MULT( ptr, oldcnt, \ |
257 |
newcnt, itmsz ) ) |
550 |
|
258 |
|
551 |
#define FT_FREE( _pointer_ ) \ |
259 |
#define FT_QALLOC( ptr, size ) \ |
552 |
FT_MEM_FREE( _pointer_ ) |
260 |
FT_MEM_SET_ERROR( FT_MEM_QALLOC( ptr, size ) ) |
553 |
|
261 |
|
|
|
262 |
#define FT_QREALLOC( ptr, cursz, newsz ) \ |
263 |
FT_MEM_SET_ERROR( FT_MEM_QREALLOC( ptr, cursz, newsz ) ) |
554 |
|
264 |
|
555 |
#define FT_NEW( _pointer_ ) \ |
265 |
#define FT_QALLOC_MULT( ptr, count, item_size ) \ |
556 |
FT_ALLOC( _pointer_, sizeof ( *(_pointer_) ) ) |
266 |
FT_MEM_SET_ERROR( FT_MEM_QALLOC_MULT( ptr, count, item_size ) ) |
557 |
|
267 |
|
558 |
#define FT_NEW_ARRAY( _pointer_, _count_ ) \ |
268 |
#define FT_QREALLOC_MULT( ptr, oldcnt, newcnt, itmsz ) \ |
559 |
FT_ALLOC( _pointer_, sizeof ( *(_pointer_) ) * (_count_) ) |
269 |
FT_MEM_SET_ERROR( FT_MEM_QREALLOC_MULT( ptr, oldcnt, \ |
|
|
270 |
newcnt, itmsz ) ) |
560 |
|
271 |
|
561 |
#define FT_RENEW_ARRAY( _pointer_, _old_, _new_ ) \ |
272 |
#define FT_FREE( ptr ) FT_MEM_FREE( ptr ) |
562 |
FT_REALLOC( _pointer_, sizeof ( *(_pointer_) ) * (_old_), \ |
|
|
563 |
sizeof ( *(_pointer_) ) * (_new_) ) |
564 |
|
273 |
|
565 |
#define FT_QNEW( _pointer_ ) \ |
274 |
#define FT_NEW( ptr ) FT_MEM_SET_ERROR( FT_MEM_NEW( ptr ) ) |
566 |
FT_QALLOC( _pointer_, sizeof ( *(_pointer_) ) ) |
|
|
567 |
|
275 |
|
568 |
#define FT_QNEW_ARRAY( _pointer_, _count_ ) \ |
276 |
#define FT_NEW_ARRAY( ptr, count ) \ |
569 |
FT_QALLOC( _pointer_, sizeof ( *(_pointer_) ) * (_count_) ) |
277 |
FT_MEM_SET_ERROR( FT_MEM_NEW_ARRAY( ptr, count ) ) |
570 |
|
278 |
|
571 |
#define FT_QRENEW_ARRAY( _pointer_, _old_, _new_ ) \ |
279 |
#define FT_RENEW_ARRAY( ptr, curcnt, newcnt ) \ |
572 |
FT_QREALLOC( _pointer_, sizeof ( *(_pointer_) ) * (_old_), \ |
280 |
FT_MEM_SET_ERROR( FT_MEM_RENEW_ARRAY( ptr, curcnt, newcnt ) ) |
573 |
sizeof ( *(_pointer_) ) * (_new_) ) |
|
|
574 |
|
281 |
|
|
|
282 |
#define FT_QNEW( ptr ) \ |
283 |
FT_MEM_SET_ERROR( FT_MEM_QNEW( ptr ) ) |
575 |
|
284 |
|
576 |
#define FT_ALLOC_ARRAY( _pointer_, _count_, _type_ ) \ |
285 |
#define FT_QNEW_ARRAY( ptr, count ) \ |
577 |
FT_ALLOC( _pointer_, (_count_) * sizeof ( _type_ ) ) |
286 |
FT_MEM_SET_ERROR( FT_MEM_NEW_ARRAY( ptr, count ) ) |
578 |
|
287 |
|
579 |
#define FT_REALLOC_ARRAY( _pointer_, _old_, _new_, _type_ ) \ |
288 |
#define FT_QRENEW_ARRAY( ptr, curcnt, newcnt ) \ |
580 |
FT_REALLOC( _pointer_, (_old_) * sizeof ( _type_ ), \ |
289 |
FT_MEM_SET_ERROR( FT_MEM_RENEW_ARRAY( ptr, curcnt, newcnt ) ) |
581 |
(_new_) * sizeof ( _type_ ) ) |
|
|
582 |
|
290 |
|
583 |
|
291 |
|
584 |
#ifdef FT_CONFIG_OPTION_OLD_INTERNALS |
292 |
#ifdef FT_CONFIG_OPTION_OLD_INTERNALS |