Lines 56-255
Link Here
|
56 |
/*************************************************************************/ |
56 |
/*************************************************************************/ |
57 |
/*************************************************************************/ |
57 |
/*************************************************************************/ |
58 |
|
58 |
|
|
|
59 |
/* C++ absolutely hates statements like p = (void*)anything; where 'p' is |
60 |
* a typed pointer. Since we don't have a typeof operator in standard C++, |
61 |
* we need some really ugly casts, like: |
62 |
*/ |
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 |
|
59 |
#ifdef FT_DEBUG_MEMORY |
71 |
#ifdef FT_DEBUG_MEMORY |
|
|
72 |
FT_BASE( const char* ) _ft_debug_file; |
73 |
FT_BASE( long ) _ft_debug_lineno; |
74 |
|
75 |
# define FT_DEBUG_INNER( exp ) ( _ft_debug_file = __FILE__, \ |
76 |
_ft_debug_lineno = __LINE__, \ |
77 |
(exp) ) |
60 |
|
78 |
|
61 |
FT_BASE( FT_Error ) |
79 |
# define FT_ASSIGNP_INNER( p, exp ) ( _ft_debug_file = __FILE__, \ |
62 |
FT_Alloc_Debug( FT_Memory memory, |
80 |
_ft_debug_lineno = __LINE__, \ |
63 |
FT_Long size, |
81 |
FT_ASSIGNP( p, exp ) ) |
64 |
void* *P, |
82 |
|
65 |
const char* file_name, |
83 |
#else /* !FT_DEBUG_MEMORY */ |
66 |
FT_Long line_no ); |
84 |
|
67 |
|
85 |
# define FT_DEBUG_INNER( exp ) (exp) |
68 |
FT_BASE( FT_Error ) |
86 |
# define FT_ASSIGNP_INNER( p, exp ) FT_ASSIGNP( p, exp ) |
69 |
FT_QAlloc_Debug( FT_Memory memory, |
87 |
|
70 |
FT_Long size, |
88 |
#endif /* !FT_DEBUG_MEMORY */ |
71 |
void* *P, |
89 |
|
72 |
const char* file_name, |
90 |
/* |
73 |
FT_Long line_no ); |
91 |
* The allocation functions return a pointer, and the error code |
74 |
|
92 |
* is written to through the `p_error' parameter. See below for |
75 |
FT_BASE( FT_Error ) |
93 |
* for documentation. |
76 |
FT_Realloc_Debug( FT_Memory memory, |
94 |
*/ |
77 |
FT_Long current, |
95 |
|
78 |
FT_Long size, |
96 |
FT_BASE( FT_Pointer ) |
79 |
void* *P, |
97 |
ft_mem_alloc( FT_Memory memory, |
80 |
const char* file_name, |
98 |
FT_Long size, |
81 |
FT_Long line_no ); |
99 |
FT_Error *p_error ); |
82 |
|
100 |
|
83 |
FT_BASE( FT_Error ) |
101 |
FT_BASE( FT_Pointer ) |
84 |
FT_QRealloc_Debug( FT_Memory memory, |
102 |
ft_mem_qalloc( FT_Memory memory, |
85 |
FT_Long current, |
103 |
FT_Long size, |
86 |
FT_Long size, |
104 |
FT_Error *p_error ); |
87 |
void* *P, |
105 |
|
88 |
const char* file_name, |
106 |
FT_BASE( FT_Pointer ) |
89 |
FT_Long line_no ); |
107 |
ft_mem_realloc( FT_Memory memory, |
|
|
108 |
FT_Long item_size, |
109 |
FT_Long cur_count, |
110 |
FT_Long new_count, |
111 |
void* block, |
112 |
FT_Error *p_error ); |
113 |
|
114 |
FT_BASE( FT_Pointer ) |
115 |
ft_mem_qrealloc( FT_Memory memory, |
116 |
FT_Long item_size, |
117 |
FT_Long cur_count, |
118 |
FT_Long new_count, |
119 |
void* block, |
120 |
FT_Error *p_error ); |
90 |
|
121 |
|
91 |
FT_BASE( void ) |
122 |
FT_BASE( void ) |
92 |
FT_Free_Debug( FT_Memory memory, |
123 |
ft_mem_free( FT_Memory memory, |
93 |
FT_Pointer block, |
124 |
const void* P ); |
94 |
const char* file_name, |
|
|
95 |
FT_Long line_no ); |
96 |
|
125 |
|
97 |
#endif |
|
|
98 |
|
126 |
|
|
|
127 |
#define FT_MEM_ALLOC( ptr, size ) \ |
128 |
FT_ASSIGNP_INNER( ptr, ft_mem_alloc( memory, (size), &error ) ) |
99 |
|
129 |
|
100 |
/*************************************************************************/ |
130 |
#define FT_MEM_FREE( ptr ) \ |
101 |
/* */ |
131 |
FT_BEGIN_STMNT \ |
102 |
/* <Function> */ |
132 |
ft_mem_free( memory, (ptr) ); \ |
103 |
/* FT_Alloc */ |
133 |
(ptr) = NULL; \ |
104 |
/* */ |
134 |
FT_END_STMNT |
105 |
/* <Description> */ |
|
|
106 |
/* Allocates a new block of memory. The returned area is always */ |
107 |
/* zero-filled; this is a strong convention in many FreeType parts. */ |
108 |
/* */ |
109 |
/* <Input> */ |
110 |
/* memory :: A handle to a given `memory object' which handles */ |
111 |
/* allocation. */ |
112 |
/* */ |
113 |
/* size :: The size in bytes of the block to allocate. */ |
114 |
/* */ |
115 |
/* <Output> */ |
116 |
/* P :: A pointer to the fresh new block. It should be set to */ |
117 |
/* NULL if `size' is 0, or in case of error. */ |
118 |
/* */ |
119 |
/* <Return> */ |
120 |
/* FreeType error code. 0 means success. */ |
121 |
/* */ |
122 |
FT_BASE( FT_Error ) |
123 |
FT_Alloc( FT_Memory memory, |
124 |
FT_Long size, |
125 |
void* *P ); |
126 |
|
135 |
|
|
|
136 |
#define FT_MEM_NEW( ptr ) \ |
137 |
FT_MEM_ALLOC( ptr, sizeof ( *(ptr) ) ) |
127 |
|
138 |
|
128 |
/*************************************************************************/ |
139 |
#define FT_MEM_REALLOC( ptr, cursz, newsz ) \ |
129 |
/* */ |
140 |
FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, 1, \ |
130 |
/* <Function> */ |
141 |
(cursz), (newsz), \ |
131 |
/* FT_QAlloc */ |
142 |
(ptr), &error ) ) |
132 |
/* */ |
|
|
133 |
/* <Description> */ |
134 |
/* Allocates a new block of memory. The returned area is *not* */ |
135 |
/* zero-filled, making allocation quicker. */ |
136 |
/* */ |
137 |
/* <Input> */ |
138 |
/* memory :: A handle to a given `memory object' which handles */ |
139 |
/* allocation. */ |
140 |
/* */ |
141 |
/* size :: The size in bytes of the block to allocate. */ |
142 |
/* */ |
143 |
/* <Output> */ |
144 |
/* P :: A pointer to the fresh new block. It should be set to */ |
145 |
/* NULL if `size' is 0, or in case of error. */ |
146 |
/* */ |
147 |
/* <Return> */ |
148 |
/* FreeType error code. 0 means success. */ |
149 |
/* */ |
150 |
FT_BASE( FT_Error ) |
151 |
FT_QAlloc( FT_Memory memory, |
152 |
FT_Long size, |
153 |
void* *p ); |
154 |
|
143 |
|
|
|
144 |
#define FT_MEM_QALLOC( ptr, size ) \ |
145 |
FT_ASSIGNP_INNER( ptr, ft_mem_qalloc( memory, (size), &error ) ) |
155 |
|
146 |
|
156 |
/*************************************************************************/ |
147 |
#define FT_MEM_QNEW( ptr ) \ |
157 |
/* */ |
148 |
FT_MEM_QALLOC( ptr, sizeof ( *(ptr) ) ) |
158 |
/* <Function> */ |
|
|
159 |
/* FT_Realloc */ |
160 |
/* */ |
161 |
/* <Description> */ |
162 |
/* Reallocates a block of memory pointed to by `*P' to `Size' bytes */ |
163 |
/* from the heap, possibly changing `*P'. The returned area is */ |
164 |
/* zero-filled. */ |
165 |
/* */ |
166 |
/* <Input> */ |
167 |
/* memory :: A handle to a given `memory object' which handles */ |
168 |
/* reallocation. */ |
169 |
/* */ |
170 |
/* current :: The current block size in bytes. */ |
171 |
/* */ |
172 |
/* size :: The new block size in bytes. */ |
173 |
/* */ |
174 |
/* <InOut> */ |
175 |
/* P :: A pointer to the fresh new block. It should be set to */ |
176 |
/* NULL if `size' is 0, or in case of error. */ |
177 |
/* */ |
178 |
/* <Return> */ |
179 |
/* FreeType error code. 0 means success. */ |
180 |
/* */ |
181 |
/* <Note> */ |
182 |
/* All callers of FT_Realloc() _must_ provide the current block size */ |
183 |
/* as well as the new one. */ |
184 |
/* */ |
185 |
FT_BASE( FT_Error ) |
186 |
FT_Realloc( FT_Memory memory, |
187 |
FT_Long current, |
188 |
FT_Long size, |
189 |
void* *P ); |
190 |
|
149 |
|
|
|
150 |
#define FT_MEM_QREALLOC( ptr, cursz, newsz ) \ |
151 |
FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, 1, \ |
152 |
(cursz), (newsz), \ |
153 |
(ptr), &error ) ) |
191 |
|
154 |
|
192 |
/*************************************************************************/ |
155 |
#define FT_MEM_QRENEW_ARRAY( ptr, cursz, newsz ) \ |
193 |
/* */ |
156 |
FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, sizeof ( *(ptr) ), \ |
194 |
/* <Function> */ |
157 |
(cursz), (newsz), \ |
195 |
/* FT_QRealloc */ |
158 |
(ptr), &error ) ) |
196 |
/* */ |
|
|
197 |
/* <Description> */ |
198 |
/* Reallocates a block of memory pointed to by `*P' to `Size' bytes */ |
199 |
/* from the heap, possibly changing `*P'. The returned area is *not* */ |
200 |
/* zero-filled, making reallocation quicker. */ |
201 |
/* */ |
202 |
/* <Input> */ |
203 |
/* memory :: A handle to a given `memory object' which handles */ |
204 |
/* reallocation. */ |
205 |
/* */ |
206 |
/* current :: The current block size in bytes. */ |
207 |
/* */ |
208 |
/* size :: The new block size in bytes. */ |
209 |
/* */ |
210 |
/* <InOut> */ |
211 |
/* P :: A pointer to the fresh new block. It should be set to */ |
212 |
/* NULL if `size' is 0, or in case of error. */ |
213 |
/* */ |
214 |
/* <Return> */ |
215 |
/* FreeType error code. 0 means success. */ |
216 |
/* */ |
217 |
/* <Note> */ |
218 |
/* All callers of FT_Realloc() _must_ provide the current block size */ |
219 |
/* as well as the new one. */ |
220 |
/* */ |
221 |
FT_BASE( FT_Error ) |
222 |
FT_QRealloc( FT_Memory memory, |
223 |
FT_Long current, |
224 |
FT_Long size, |
225 |
void* *p ); |
226 |
|
159 |
|
|
|
160 |
#define FT_MEM_ALLOC_MULT( ptr, count, item_size ) \ |
161 |
FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, (item_size), \ |
162 |
0, (count), \ |
163 |
NULL, &error ) ) |
227 |
|
164 |
|
228 |
/*************************************************************************/ |
165 |
#define FT_MEM_REALLOC_MULT( ptr, oldcnt, newcnt, itmsz ) \ |
229 |
/* */ |
166 |
FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, (itmsz), \ |
230 |
/* <Function> */ |
167 |
(oldcnt), (newcnt), \ |
231 |
/* FT_Free */ |
168 |
(ptr), &error ) ) |
232 |
/* */ |
169 |
|
233 |
/* <Description> */ |
170 |
#define FT_MEM_QALLOC_MULT( ptr, count, item_size ) \ |
234 |
/* Releases a given block of memory allocated through FT_Alloc(). */ |
171 |
FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, (item_size), \ |
235 |
/* */ |
172 |
0, (count), \ |
236 |
/* <Input> */ |
173 |
NULL, &error ) ) |
237 |
/* memory :: A handle to a given `memory object' which handles */ |
174 |
|
238 |
/* memory deallocation */ |
175 |
#define FT_MEM_QREALLOC_MULT( ptr, oldcnt, newcnt, itmsz) \ |
239 |
/* */ |
176 |
FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, (itmsz), \ |
240 |
/* P :: This is the _address_ of a _pointer_ which points to the */ |
177 |
(oldcnt), (newcnt), \ |
241 |
/* allocated block. It is always set to NULL on exit. */ |
178 |
(ptr), &error ) ) |
242 |
/* */ |
|
|
243 |
/* <Note> */ |
244 |
/* If P or *P is NULL, this function should return successfully. */ |
245 |
/* This is a strong convention within all of FreeType and its */ |
246 |
/* drivers. */ |
247 |
/* */ |
248 |
FT_BASE( void ) |
249 |
FT_Free( FT_Memory memory, |
250 |
void* *P ); |
251 |
|
179 |
|
252 |
|
180 |
|
|
|
181 |
#define FT_MEM_SET_ERROR( cond ) ( (cond), error != 0 ) |
182 |
|
253 |
#define FT_MEM_SET( dest, byte, count ) ft_memset( dest, byte, count ) |
183 |
#define FT_MEM_SET( dest, byte, count ) ft_memset( dest, byte, count ) |
254 |
|
184 |
|
255 |
#define FT_MEM_COPY( dest, source, count ) ft_memcpy( dest, source, count ) |
185 |
#define FT_MEM_COPY( dest, source, count ) ft_memcpy( dest, source, count ) |
Lines 280-372
Link Here
|
280 |
|
210 |
|
281 |
#define FT_ARRAY_CHECK( ptr, count ) ( (count) <= FT_ARRAY_MAX( ptr ) ) |
211 |
#define FT_ARRAY_CHECK( ptr, count ) ( (count) <= FT_ARRAY_MAX( ptr ) ) |
282 |
|
212 |
|
283 |
|
|
|
284 |
/*************************************************************************/ |
213 |
/*************************************************************************/ |
285 |
/* */ |
214 |
/* */ |
286 |
/* We first define FT_MEM_ALLOC, FT_MEM_REALLOC, and FT_MEM_FREE. All */ |
215 |
/* The following functions macros expect that their pointer argument is */ |
287 |
/* macros use an _implicit_ `memory' parameter to access the current */ |
216 |
/* _typed_ in order to automatically compute array element sizes. */ |
288 |
/* memory allocator. */ |
|
|
289 |
/* */ |
217 |
/* */ |
290 |
|
218 |
|
291 |
#ifdef FT_DEBUG_MEMORY |
219 |
#define FT_MEM_NEW_ARRAY( ptr, count ) \ |
|
|
220 |
FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, sizeof ( *(ptr) ), \ |
221 |
0, (count), \ |
222 |
NULL, &error ) ) |
292 |
|
223 |
|
293 |
#define FT_MEM_ALLOC( _pointer_, _size_ ) \ |
224 |
#define FT_MEM_RENEW_ARRAY( ptr, cursz, newsz ) \ |
294 |
FT_Alloc_Debug( memory, _size_, \ |
225 |
FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, sizeof ( *(ptr) ), \ |
295 |
(void**)(void*)&(_pointer_), \ |
226 |
(cursz), (newsz), \ |
296 |
__FILE__, __LINE__ ) |
227 |
(ptr), &error ) ) |
297 |
|
228 |
|
298 |
#define FT_MEM_REALLOC( _pointer_, _current_, _size_ ) \ |
229 |
#define FT_MEM_QNEW_ARRAY( ptr, count ) \ |
299 |
FT_Realloc_Debug( memory, _current_, _size_, \ |
230 |
FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, sizeof ( *(ptr) ), \ |
300 |
(void**)(void*)&(_pointer_), \ |
231 |
0, (count), \ |
301 |
__FILE__, __LINE__ ) |
232 |
NULL, &error ) ) |
302 |
|
233 |
|
303 |
#define FT_MEM_QALLOC( _pointer_, _size_ ) \ |
234 |
#define FT_MEM_QRENEW_ARRAY( ptr, cursz, newsz ) \ |
304 |
FT_QAlloc_Debug( memory, _size_, \ |
235 |
FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, sizeof ( *(ptr) ), \ |
305 |
(void**)(void*)&(_pointer_), \ |
236 |
(cursz), (newsz), \ |
306 |
__FILE__, __LINE__ ) |
237 |
(ptr), &error ) ) |
307 |
|
238 |
|
308 |
#define FT_MEM_QREALLOC( _pointer_, _current_, _size_ ) \ |
239 |
#define FT_ALLOC( ptr, size ) \ |
309 |
FT_QRealloc_Debug( memory, _current_, _size_, \ |
240 |
FT_MEM_SET_ERROR( FT_MEM_ALLOC( ptr, size ) ) |
310 |
(void**)(void*)&(_pointer_), \ |
|
|
311 |
__FILE__, __LINE__ ) |
312 |
|
241 |
|
313 |
#define FT_MEM_FREE( _pointer_ ) \ |
242 |
#define FT_REALLOC( ptr, cursz, newsz ) \ |
314 |
FT_Free_Debug( memory, (void**)(void*)&(_pointer_), \ |
243 |
FT_MEM_SET_ERROR( FT_MEM_REALLOC( ptr, cursz, newsz ) ) |
315 |
__FILE__, __LINE__ ) |
|
|
316 |
|
244 |
|
|
|
245 |
#define FT_ALLOC_MULT( ptr, count, item_size ) \ |
246 |
FT_MEM_SET_ERROR( FT_MEM_ALLOC_MULT( ptr, count, item_size ) ) |
317 |
|
247 |
|
318 |
#else /* !FT_DEBUG_MEMORY */ |
248 |
#define FT_REALLOC_MULT( ptr, oldcnt, newcnt, itmsz ) \ |
|
|
249 |
FT_MEM_SET_ERROR( FT_MEM_REALLOC_MULT( ptr, oldcnt, \ |
250 |
newcnt, itmsz ) ) |
319 |
|
251 |
|
|
|
252 |
#define FT_QALLOC( ptr, size ) \ |
253 |
FT_MEM_SET_ERROR( FT_MEM_QALLOC( ptr, size ) ) |
320 |
|
254 |
|
321 |
#define FT_MEM_ALLOC( _pointer_, _size_ ) \ |
255 |
#define FT_QREALLOC( ptr, cursz, newsz ) \ |
322 |
FT_Alloc( memory, _size_, \ |
256 |
FT_MEM_SET_ERROR( FT_MEM_QREALLOC( ptr, cursz, newsz ) ) |
323 |
(void**)(void*)&(_pointer_) ) |
|
|
324 |
|
257 |
|
325 |
#define FT_MEM_FREE( _pointer_ ) \ |
258 |
#define FT_QALLOC_MULT( ptr, count, item_size ) \ |
326 |
FT_Free( memory, \ |
259 |
FT_MEM_SET_ERROR( FT_MEM_QALLOC_MULT( ptr, count, item_size ) ) |
327 |
(void**)(void*)&(_pointer_) ) |
|
|
328 |
|
260 |
|
329 |
#define FT_MEM_REALLOC( _pointer_, _current_, _size_ ) \ |
261 |
#define FT_QREALLOC_MULT( ptr, oldcnt, newcnt, itmsz ) \ |
330 |
FT_Realloc( memory, _current_, _size_, \ |
262 |
FT_MEM_SET_ERROR( FT_MEM_QREALLOC_MULT( ptr, oldcnt, \ |
331 |
(void**)(void*)&(_pointer_) ) |
263 |
newcnt, itmsz ) ) |
332 |
|
264 |
|
333 |
#define FT_MEM_QALLOC( _pointer_, _size_ ) \ |
265 |
#define FT_FREE( ptr ) FT_MEM_FREE( ptr ) |
334 |
FT_QAlloc( memory, _size_, \ |
|
|
335 |
(void**)(void*)&(_pointer_) ) |
336 |
|
266 |
|
337 |
#define FT_MEM_QREALLOC( _pointer_, _current_, _size_ ) \ |
267 |
#define FT_NEW( ptr ) FT_MEM_SET_ERROR( FT_MEM_NEW( ptr ) ) |
338 |
FT_QRealloc( memory, _current_, _size_, \ |
|
|
339 |
(void**)(void*)&(_pointer_) ) |
340 |
|
268 |
|
341 |
#endif /* !FT_DEBUG_MEMORY */ |
269 |
#define FT_NEW_ARRAY( ptr, count ) \ |
|
|
270 |
FT_MEM_SET_ERROR( FT_MEM_NEW_ARRAY( ptr, count ) ) |
342 |
|
271 |
|
|
|
272 |
#define FT_RENEW_ARRAY( ptr, curcnt, newcnt ) \ |
273 |
FT_MEM_SET_ERROR( FT_MEM_RENEW_ARRAY( ptr, curcnt, newcnt ) ) |
343 |
|
274 |
|
344 |
/*************************************************************************/ |
275 |
#define FT_QNEW( ptr ) \ |
345 |
/* */ |
276 |
FT_MEM_SET_ERROR( FT_MEM_QNEW( ptr ) ) |
346 |
/* The following functions macros expect that their pointer argument is */ |
|
|
347 |
/* _typed_ in order to automatically compute array element sizes. */ |
348 |
/* */ |
349 |
|
350 |
#define FT_MEM_NEW( _pointer_ ) \ |
351 |
FT_MEM_ALLOC( _pointer_, sizeof ( *(_pointer_) ) ) |
352 |
|
353 |
#define FT_MEM_NEW_ARRAY( _pointer_, _count_ ) \ |
354 |
FT_MEM_ALLOC( _pointer_, (_count_) * sizeof ( *(_pointer_) ) ) |
355 |
|
356 |
#define FT_MEM_RENEW_ARRAY( _pointer_, _old_, _new_ ) \ |
357 |
FT_MEM_REALLOC( _pointer_, (_old_) * sizeof ( *(_pointer_) ), \ |
358 |
(_new_) * sizeof ( *(_pointer_) ) ) |
359 |
|
277 |
|
360 |
#define FT_MEM_QNEW( _pointer_ ) \ |
278 |
#define FT_QNEW_ARRAY( ptr, count ) \ |
361 |
FT_MEM_QALLOC( _pointer_, sizeof ( *(_pointer_) ) ) |
279 |
FT_MEM_SET_ERROR( FT_MEM_NEW_ARRAY( ptr, count ) ) |
362 |
|
|
|
363 |
#define FT_MEM_QNEW_ARRAY( _pointer_, _count_ ) \ |
364 |
FT_MEM_QALLOC( _pointer_, (_count_) * sizeof ( *(_pointer_) ) ) |
365 |
|
366 |
#define FT_MEM_QRENEW_ARRAY( _pointer_, _old_, _new_ ) \ |
367 |
FT_MEM_QREALLOC( _pointer_, (_old_) * sizeof ( *(_pointer_) ), \ |
368 |
(_new_) * sizeof ( *(_pointer_) ) ) |
369 |
|
280 |
|
|
|
281 |
#define FT_QRENEW_ARRAY( ptr, curcnt, newcnt ) \ |
282 |
FT_MEM_SET_ERROR( FT_MEM_RENEW_ARRAY( ptr, curcnt, newcnt ) ) |
370 |
|
283 |
|
371 |
/*************************************************************************/ |
284 |
/*************************************************************************/ |
372 |
/* */ |
285 |
/* */ |
Lines 388-431
Link Here
|
388 |
/* if an error occured (i.e. if 'error != 0'). */ |
301 |
/* if an error occured (i.e. if 'error != 0'). */ |
389 |
/* */ |
302 |
/* */ |
390 |
|
303 |
|
391 |
#define FT_ALLOC( _pointer_, _size_ ) \ |
|
|
392 |
FT_SET_ERROR( FT_MEM_ALLOC( _pointer_, _size_ ) ) |
393 |
|
394 |
#define FT_REALLOC( _pointer_, _current_, _size_ ) \ |
395 |
FT_SET_ERROR( FT_MEM_REALLOC( _pointer_, _current_, _size_ ) ) |
396 |
|
397 |
#define FT_QALLOC( _pointer_, _size_ ) \ |
398 |
FT_SET_ERROR( FT_MEM_QALLOC( _pointer_, _size_ ) ) |
399 |
|
400 |
#define FT_QREALLOC( _pointer_, _current_, _size_ ) \ |
401 |
FT_SET_ERROR( FT_MEM_QREALLOC( _pointer_, _current_, _size_ ) ) |
402 |
|
403 |
|
404 |
#define FT_FREE( _pointer_ ) \ |
405 |
FT_MEM_FREE( _pointer_ ) |
406 |
|
407 |
|
408 |
#define FT_NEW( _pointer_ ) \ |
409 |
FT_ALLOC( _pointer_, sizeof ( *(_pointer_) ) ) |
410 |
|
411 |
#define FT_NEW_ARRAY( _pointer_, _count_ ) \ |
412 |
FT_ALLOC( _pointer_, sizeof ( *(_pointer_) ) * (_count_) ) |
413 |
|
414 |
#define FT_RENEW_ARRAY( _pointer_, _old_, _new_ ) \ |
415 |
FT_REALLOC( _pointer_, sizeof ( *(_pointer_) ) * (_old_), \ |
416 |
sizeof ( *(_pointer_) ) * (_new_) ) |
417 |
|
418 |
#define FT_QNEW( _pointer_ ) \ |
419 |
FT_QALLOC( _pointer_, sizeof ( *(_pointer_) ) ) |
420 |
|
421 |
#define FT_QNEW_ARRAY( _pointer_, _count_ ) \ |
422 |
FT_QALLOC( _pointer_, sizeof ( *(_pointer_) ) * (_count_) ) |
423 |
|
424 |
#define FT_QRENEW_ARRAY( _pointer_, _old_, _new_ ) \ |
425 |
FT_QREALLOC( _pointer_, sizeof ( *(_pointer_) ) * (_old_), \ |
426 |
sizeof ( *(_pointer_) ) * (_new_) ) |
427 |
|
428 |
|
429 |
#define FT_ALLOC_ARRAY( _pointer_, _count_, _type_ ) \ |
304 |
#define FT_ALLOC_ARRAY( _pointer_, _count_, _type_ ) \ |
430 |
FT_ALLOC( _pointer_, (_count_) * sizeof ( _type_ ) ) |
305 |
FT_ALLOC( _pointer_, (_count_) * sizeof ( _type_ ) ) |
431 |
|
306 |
|