| OLD | NEW |
| 1 /***************************************************************************/ | 1 /***************************************************************************/ |
| 2 /* */ | 2 /* */ |
| 3 /* ftmemory.h */ | 3 /* ftmemory.h */ |
| 4 /* */ | 4 /* */ |
| 5 /* The FreeType memory management macros (specification). */ | 5 /* The FreeType memory management macros (specification). */ |
| 6 /* */ | 6 /* */ |
| 7 /* Copyright 1996-2002, 2004-2007, 2010, 2013 by */ | 7 /* Copyright 1996-2002, 2004-2007, 2010, 2013 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 #ifndef __FTMEMORY_H__ | 19 #ifndef __FTMEMORY_H__ |
| 20 #define __FTMEMORY_H__ | 20 #define __FTMEMORY_H__ |
| 21 | 21 |
| 22 | 22 |
| 23 #include "../../ft2build.h" | 23 #include <ft2build.h> |
| 24 #include "../config/ftconfig.h" | 24 #include FT_CONFIG_CONFIG_H |
| 25 #include "../fttypes.h" | 25 #include FT_TYPES_H |
| 26 | 26 |
| 27 | 27 |
| 28 FT_BEGIN_HEADER | 28 FT_BEGIN_HEADER |
| 29 | 29 |
| 30 | 30 |
| 31 /*************************************************************************/ | 31 /*************************************************************************/ |
| 32 /* */ | 32 /* */ |
| 33 /* <Macro> */ | 33 /* <Macro> */ |
| 34 /* FT_SET_ERROR */ | 34 /* FT_SET_ERROR */ |
| 35 /* */ | 35 /* */ |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 void* block, | 128 void* block, |
| 129 FT_Error *p_error ); | 129 FT_Error *p_error ); |
| 130 | 130 |
| 131 FT_BASE( FT_Pointer ) | 131 FT_BASE( FT_Pointer ) |
| 132 ft_mem_qrealloc( FT_Memory memory, | 132 ft_mem_qrealloc( FT_Memory memory, |
| 133 FT_Long item_size, | 133 FT_Long item_size, |
| 134 FT_Long cur_count, | 134 FT_Long cur_count, |
| 135 FT_Long new_count, | 135 FT_Long new_count, |
| 136 void* block, | 136 void* block, |
| 137 FT_Error *p_error ); | 137 FT_Error *p_error ); |
| 138 #ifdef _DEBUG | |
| 139 //#define _XYQ_MEM_DEBUG | |
| 140 #endif | |
| 141 | |
| 142 #ifdef _XYQ_MEM_DEBUG /* XYQ */ | |
| 143 FT_BASE( FT_Pointer ) | |
| 144 ft_mem_allocdebug( FT_Memory memory, | |
| 145 FT_Long size, const char* filename, int line, | |
| 146 FT_Error *p_error ); | |
| 147 | |
| 148 FT_BASE( FT_Pointer ) | |
| 149 ft_mem_qallocdebug( FT_Memory memory, | |
| 150 FT_Long size, const char* filename, int line, | |
| 151 FT_Error *p_error ); | |
| 152 | |
| 153 FT_BASE( FT_Pointer ) | |
| 154 ft_mem_reallocdebug( FT_Memory memory, | |
| 155 FT_Long item_size, | |
| 156 FT_Long cur_count, | |
| 157 FT_Long new_count, | |
| 158 void* block, const char* filename, int line, | |
| 159 FT_Error *p_error ); | |
| 160 | |
| 161 FT_BASE( FT_Pointer ) | |
| 162 ft_mem_qreallocdebug( FT_Memory memory, | |
| 163 FT_Long item_size, | |
| 164 FT_Long cur_count, | |
| 165 FT_Long new_count, | |
| 166 void* block, const char* filename, int line, | |
| 167 FT_Error *p_error ); | |
| 168 #endif | |
| 169 | |
| 170 | 138 |
| 171 FT_BASE( void ) | 139 FT_BASE( void ) |
| 172 ft_mem_free( FT_Memory memory, | 140 ft_mem_free( FT_Memory memory, |
| 173 const void* P ); | 141 const void* P ); |
| 174 | 142 |
| 175 | 143 |
| 144 #define FT_MEM_ALLOC( ptr, size ) \ |
| 145 FT_ASSIGNP_INNER( ptr, ft_mem_alloc( memory, \ |
| 146 (FT_Long)(size), \ |
| 147 &error ) ) |
| 148 |
| 176 #define FT_MEM_FREE( ptr ) \ | 149 #define FT_MEM_FREE( ptr ) \ |
| 177 FT_BEGIN_STMNT \ | 150 FT_BEGIN_STMNT \ |
| 178 ft_mem_free( memory, (ptr) ); \ | 151 ft_mem_free( memory, (ptr) ); \ |
| 179 (ptr) = NULL; \ | 152 (ptr) = NULL; \ |
| 180 FT_END_STMNT | 153 FT_END_STMNT |
| 181 #ifndef _XYQ_MEM_DEBUG | |
| 182 #define FT_MEM_ALLOC( ptr, size ) \ | |
| 183 FT_ASSIGNP_INNER( ptr, ft_mem_alloc( memory, (size), &error )
) | |
| 184 | 154 |
| 155 #define FT_MEM_NEW( ptr ) \ |
| 156 FT_MEM_ALLOC( ptr, sizeof ( *(ptr) ) ) |
| 185 | 157 |
| 186 #define FT_MEM_REALLOC( ptr, cursz, newsz ) \ | 158 #define FT_MEM_REALLOC( ptr, cursz, newsz ) \ |
| 187 FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \ | 159 FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \ |
| 188 1, \ | 160 1, \ |
| 189 (FT_Long)(cursz), \ | 161 (FT_Long)(cursz), \ |
| 190 (FT_Long)(newsz), \ | 162 (FT_Long)(newsz), \ |
| 191 (ptr), \ | 163 (ptr), \ |
| 192 &error ) ) | 164 &error ) ) |
| 193 | 165 |
| 194 #define FT_MEM_QALLOC( ptr, size ) \ | 166 #define FT_MEM_QALLOC( ptr, size ) \ |
| 195 FT_ASSIGNP_INNER( ptr, ft_mem_qalloc( memory, \ | 167 FT_ASSIGNP_INNER( ptr, ft_mem_qalloc( memory, \ |
| 196 (FT_Long)(size), \ | 168 (FT_Long)(size), \ |
| 197 &error ) ) | 169 &error ) ) |
| 198 | 170 |
| 171 #define FT_MEM_QNEW( ptr ) \ |
| 172 FT_MEM_QALLOC( ptr, sizeof ( *(ptr) ) ) |
| 173 |
| 199 #define FT_MEM_QREALLOC( ptr, cursz, newsz ) \ | 174 #define FT_MEM_QREALLOC( ptr, cursz, newsz ) \ |
| 200 FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, \ | 175 FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, \ |
| 201 1, \ | 176 1, \ |
| 202 (FT_Long)(cursz), \ | 177 (FT_Long)(cursz), \ |
| 203 (FT_Long)(newsz), \ | 178 (FT_Long)(newsz), \ |
| 204 (ptr), \ | 179 (ptr), \ |
| 205 &error ) ) | 180 &error ) ) |
| 206 | 181 |
| 207 #define FT_MEM_ALLOC_MULT( ptr, count, item_size ) \ | 182 #define FT_MEM_ALLOC_MULT( ptr, count, item_size ) \ |
| 208 FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \ | 183 FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \ |
| (...skipping 19 matching lines...) Expand all Loading... |
| 228 NULL, \ | 203 NULL, \ |
| 229 &error ) ) | 204 &error ) ) |
| 230 | 205 |
| 231 #define FT_MEM_QREALLOC_MULT( ptr, oldcnt, newcnt, itmsz) \ | 206 #define FT_MEM_QREALLOC_MULT( ptr, oldcnt, newcnt, itmsz) \ |
| 232 FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, \ | 207 FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, \ |
| 233 (FT_Long)(itmsz), \ | 208 (FT_Long)(itmsz), \ |
| 234 (FT_Long)(oldcnt), \ | 209 (FT_Long)(oldcnt), \ |
| 235 (FT_Long)(newcnt), \ | 210 (FT_Long)(newcnt), \ |
| 236 (ptr), \ | 211 (ptr), \ |
| 237 &error ) ) | 212 &error ) ) |
| 238 #define FT_MEM_NEW_ARRAY( ptr, count ) \ | |
| 239 FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, sizeof ( *(ptr) ), \ | |
| 240 0, (count), \ | |
| 241 NULL, &error ) ) | |
| 242 | 213 |
| 243 #define FT_MEM_RENEW_ARRAY( ptr, cursz, newsz ) \ | |
| 244 FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, sizeof ( *(ptr) ), \ | |
| 245 (cursz), (newsz), \ | |
| 246 (ptr), &error ) ) | |
| 247 | |
| 248 #define FT_MEM_QNEW_ARRAY( ptr, count ) \ | |
| 249 FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, sizeof ( *(ptr) ), \ | |
| 250 0, (count), \ | |
| 251 NULL, &error ) ) | |
| 252 | |
| 253 #define FT_MEM_QRENEW_ARRAY( ptr, cursz, newsz ) \ | |
| 254 FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, sizeof ( *(ptr) ), \ | |
| 255 (cursz), (newsz), \ | |
| 256 (ptr), &error ) ) | |
| 257 | |
| 258 #else | |
| 259 #define FT_MEM_ALLOC( ptr, size ) \ | |
| 260 FT_ASSIGNP_INNER( ptr, ft_mem_allocdebug( memory, (size), __FILE__, __LINE__,
&error ) ) | |
| 261 | |
| 262 #define FT_MEM_REALLOC( ptr, cursz, newsz ) \ | |
| 263 FT_ASSIGNP_INNER( ptr, ft_mem_reallocdebug( memory, 1, \ | |
| 264 (cursz), (newsz), \ | |
| 265 (ptr), __FILE__, __LINE__, &err
or ) ) | |
| 266 | |
| 267 #define FT_MEM_QALLOC( ptr, size ) \ | |
| 268 FT_ASSIGNP_INNER( ptr, ft_mem_qallocdebug( memory, (size), __FILE__, _
_LINE__, &error ) ) | |
| 269 | |
| 270 #define FT_MEM_QREALLOC( ptr, cursz, newsz ) \ | |
| 271 FT_ASSIGNP_INNER( ptr, ft_mem_qreallocdebug( memory, 1, \ | |
| 272 (cursz), (newsz), \ | |
| 273 (ptr), __FILE__, __LINE__, &er
ror ) ) | |
| 274 | |
| 275 #define FT_MEM_ALLOC_MULT( ptr, count, item_size ) \ | |
| 276 FT_ASSIGNP_INNER( ptr, ft_mem_reallocdebug( memory, (item_size), \ | |
| 277 0, (count), \ | |
| 278 NULL, __FILE__, __LINE__, &erro
r ) ) | |
| 279 | |
| 280 #define FT_MEM_REALLOC_MULT( ptr, oldcnt, newcnt, itmsz ) \ | |
| 281 FT_ASSIGNP_INNER( ptr, ft_mem_reallocdebug( memory, (itmsz), \ | |
| 282 (oldcnt), (newcnt), \ | |
| 283 (ptr), __FILE__, __LINE__, &err
or ) ) | |
| 284 | |
| 285 #define FT_MEM_QALLOC_MULT( ptr, count, item_size ) \ | |
| 286 FT_ASSIGNP_INNER( ptr, ft_mem_qreallocdebug( memory, (item_size), \ | |
| 287 0, (count), \ | |
| 288 NULL, __FILE__, __LINE__, &err
or ) ) | |
| 289 | |
| 290 #define FT_MEM_QREALLOC_MULT( ptr, oldcnt, newcnt, itmsz) \ | |
| 291 FT_ASSIGNP_INNER( ptr, ft_mem_qreallocdebug( memory, (itmsz), \ | |
| 292 (oldcnt), (newcnt), \ | |
| 293 (ptr), __FILE__, __LINE__, &er
ror ) ) | |
| 294 /*************************************************************************/ | |
| 295 /* */ | |
| 296 /* The following functions macros expect that their pointer argument is */ | |
| 297 /* _typed_ in order to automatically compute array element sizes. */ | |
| 298 /* */ | |
| 299 | |
| 300 #define FT_MEM_NEW_ARRAY( ptr, count ) \ | |
| 301 FT_ASSIGNP_INNER( ptr, ft_mem_reallocdebug( memory, sizeof ( *(ptr) ),
\ | |
| 302 0, (count), \ | |
| 303 NULL, __FILE__, __LINE__, &erro
r ) ) | |
| 304 | |
| 305 #define FT_MEM_RENEW_ARRAY( ptr, cursz, newsz ) \ | |
| 306 FT_ASSIGNP_INNER( ptr, ft_mem_reallocdebug( memory, sizeof ( *(ptr) ),
\ | |
| 307 (cursz), (newsz), \ | |
| 308 (ptr), __FILE__, __LINE__, &err
or ) ) | |
| 309 | |
| 310 #define FT_MEM_QNEW_ARRAY( ptr, count ) \ | |
| 311 FT_ASSIGNP_INNER( ptr, ft_mem_qreallocdebug( memory, sizeof ( *(ptr) )
, \ | |
| 312 0, (count), \ | |
| 313 NULL, __FILE__, __LINE__, &err
or ) ) | |
| 314 | |
| 315 #define FT_MEM_QRENEW_ARRAY( ptr, cursz, newsz ) \ | |
| 316 FT_ASSIGNP_INNER( ptr, ft_mem_qreallocdebug( memory, sizeof ( *(ptr) )
, \ | |
| 317 (cursz), (newsz), \ | |
| 318 (ptr), __FILE__, __LINE__, &er
ror ) ) | |
| 319 | |
| 320 #endif | |
| 321 | |
| 322 #define FT_MEM_NEW( ptr ) \ | |
| 323 FT_MEM_ALLOC( ptr, sizeof ( *(ptr) ) ) | |
| 324 | |
| 325 #define FT_MEM_QNEW( ptr ) \ | |
| 326 FT_MEM_QALLOC( ptr, sizeof ( *(ptr) ) ) | |
| 327 | 214 |
| 328 #define FT_MEM_SET_ERROR( cond ) ( (cond), error != 0 ) | 215 #define FT_MEM_SET_ERROR( cond ) ( (cond), error != 0 ) |
| 329 | 216 |
| 330 | 217 |
| 331 #define FT_MEM_SET( dest, byte, count ) ft_memset( dest, byte, count ) | 218 #define FT_MEM_SET( dest, byte, count ) ft_memset( dest, byte, count ) |
| 332 | 219 |
| 333 #define FT_MEM_COPY( dest, source, count ) ft_memcpy( dest, source, count ) | 220 #define FT_MEM_COPY( dest, source, count ) ft_memcpy( dest, source, count ) |
| 334 | 221 |
| 335 #define FT_MEM_MOVE( dest, source, count ) ft_memmove( dest, source, count ) | 222 #define FT_MEM_MOVE( dest, source, count ) ft_memmove( dest, source, count ) |
| 336 | 223 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 359 | 246 |
| 360 #define FT_ARRAY_CHECK( ptr, count ) ( (count) <= FT_ARRAY_MAX( ptr ) ) | 247 #define FT_ARRAY_CHECK( ptr, count ) ( (count) <= FT_ARRAY_MAX( ptr ) ) |
| 361 | 248 |
| 362 | 249 |
| 363 /*************************************************************************/ | 250 /*************************************************************************/ |
| 364 /* */ | 251 /* */ |
| 365 /* The following functions macros expect that their pointer argument is */ | 252 /* The following functions macros expect that their pointer argument is */ |
| 366 /* _typed_ in order to automatically compute array element sizes. */ | 253 /* _typed_ in order to automatically compute array element sizes. */ |
| 367 /* */ | 254 /* */ |
| 368 | 255 |
| 256 #define FT_MEM_NEW_ARRAY( ptr, count ) \ |
| 257 FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \ |
| 258 sizeof ( *(ptr) ), \ |
| 259 0, \ |
| 260 (FT_Long)(count), \ |
| 261 NULL, \ |
| 262 &error ) ) |
| 263 |
| 264 #define FT_MEM_RENEW_ARRAY( ptr, cursz, newsz ) \ |
| 265 FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \ |
| 266 sizeof ( *(ptr) ), \ |
| 267 (FT_Long)(cursz), \ |
| 268 (FT_Long)(newsz), \ |
| 269 (ptr), \ |
| 270 &error ) ) |
| 271 |
| 272 #define FT_MEM_QNEW_ARRAY( ptr, count ) \ |
| 273 FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, \ |
| 274 sizeof ( *(ptr) ), \ |
| 275 0, \ |
| 276 (FT_Long)(count), \ |
| 277 NULL, \ |
| 278 &error ) ) |
| 279 |
| 280 #define FT_MEM_QRENEW_ARRAY( ptr, cursz, newsz ) \ |
| 281 FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, \ |
| 282 sizeof ( *(ptr) ), \ |
| 283 (FT_Long)(cursz), \ |
| 284 (FT_Long)(newsz), \ |
| 285 (ptr), \ |
| 286 &error ) ) |
| 287 |
| 369 #define FT_ALLOC( ptr, size ) \ | 288 #define FT_ALLOC( ptr, size ) \ |
| 370 FT_MEM_SET_ERROR( FT_MEM_ALLOC( ptr, size ) ) | 289 FT_MEM_SET_ERROR( FT_MEM_ALLOC( ptr, size ) ) |
| 371 | 290 |
| 372 #define FT_REALLOC( ptr, cursz, newsz ) \ | 291 #define FT_REALLOC( ptr, cursz, newsz ) \ |
| 373 FT_MEM_SET_ERROR( FT_MEM_REALLOC( ptr, cursz, newsz ) ) | 292 FT_MEM_SET_ERROR( FT_MEM_REALLOC( ptr, cursz, newsz ) ) |
| 374 | 293 |
| 375 #define FT_ALLOC_MULT( ptr, count, item_size ) \ | 294 #define FT_ALLOC_MULT( ptr, count, item_size ) \ |
| 376 FT_MEM_SET_ERROR( FT_MEM_ALLOC_MULT( ptr, count, item_size ) ) | 295 FT_MEM_SET_ERROR( FT_MEM_ALLOC_MULT( ptr, count, item_size ) ) |
| 377 | 296 |
| 378 #define FT_REALLOC_MULT( ptr, oldcnt, newcnt, itmsz ) \ | 297 #define FT_REALLOC_MULT( ptr, oldcnt, newcnt, itmsz ) \ |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 | 369 |
| 451 /* */ | 370 /* */ |
| 452 | 371 |
| 453 | 372 |
| 454 FT_END_HEADER | 373 FT_END_HEADER |
| 455 | 374 |
| 456 #endif /* __FTMEMORY_H__ */ | 375 #endif /* __FTMEMORY_H__ */ |
| 457 | 376 |
| 458 | 377 |
| 459 /* END */ | 378 /* END */ |
| OLD | NEW |