| 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-2001, 2002, 2004, 2005, 2006, 2007, 2010 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 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 | 138 |
| 139 FT_BASE( void ) | 139 FT_BASE( void ) |
| 140 ft_mem_free( FT_Memory memory, | 140 ft_mem_free( FT_Memory memory, |
| 141 const void* P ); | 141 const void* P ); |
| 142 | 142 |
| 143 | 143 |
| 144 #define FT_MEM_ALLOC( ptr, size ) \ | 144 #define FT_MEM_ALLOC( ptr, size ) \ |
| 145 FT_ASSIGNP_INNER( ptr, ft_mem_alloc( memory, (size), &error ) ) | 145 FT_ASSIGNP_INNER( ptr, ft_mem_alloc( memory, \ |
| 146 (FT_Long)(size), \ |
| 147 &error ) ) |
| 146 | 148 |
| 147 #define FT_MEM_FREE( ptr ) \ | 149 #define FT_MEM_FREE( ptr ) \ |
| 148 FT_BEGIN_STMNT \ | 150 FT_BEGIN_STMNT \ |
| 149 ft_mem_free( memory, (ptr) ); \ | 151 ft_mem_free( memory, (ptr) ); \ |
| 150 (ptr) = NULL; \ | 152 (ptr) = NULL; \ |
| 151 FT_END_STMNT | 153 FT_END_STMNT |
| 152 | 154 |
| 153 #define FT_MEM_NEW( ptr ) \ | 155 #define FT_MEM_NEW( ptr ) \ |
| 154 FT_MEM_ALLOC( ptr, sizeof ( *(ptr) ) ) | 156 FT_MEM_ALLOC( ptr, sizeof ( *(ptr) ) ) |
| 155 | 157 |
| 156 #define FT_MEM_REALLOC( ptr, cursz, newsz ) \ | 158 #define FT_MEM_REALLOC( ptr, cursz, newsz ) \ |
| 157 FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, 1, \ | 159 FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \ |
| 158 (cursz), (newsz), \ | 160 1, \ |
| 159 (ptr), &error ) ) | 161 (FT_Long)(cursz), \ |
| 162 (FT_Long)(newsz), \ |
| 163 (ptr), \ |
| 164 &error ) ) |
| 160 | 165 |
| 161 #define FT_MEM_QALLOC( ptr, size ) \ | 166 #define FT_MEM_QALLOC( ptr, size ) \ |
| 162 FT_ASSIGNP_INNER( ptr, ft_mem_qalloc( memory, (size), &error ) ) | 167 FT_ASSIGNP_INNER( ptr, ft_mem_qalloc( memory, \ |
| 168 (FT_Long)(size), \ |
| 169 &error ) ) |
| 163 | 170 |
| 164 #define FT_MEM_QNEW( ptr ) \ | 171 #define FT_MEM_QNEW( ptr ) \ |
| 165 FT_MEM_QALLOC( ptr, sizeof ( *(ptr) ) ) | 172 FT_MEM_QALLOC( ptr, sizeof ( *(ptr) ) ) |
| 166 | 173 |
| 167 #define FT_MEM_QREALLOC( ptr, cursz, newsz ) \ | 174 #define FT_MEM_QREALLOC( ptr, cursz, newsz ) \ |
| 168 FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, 1, \ | 175 FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, \ |
| 169 (cursz), (newsz), \ | 176 1, \ |
| 170 (ptr), &error ) ) | 177 (FT_Long)(cursz), \ |
| 178 (FT_Long)(newsz), \ |
| 179 (ptr), \ |
| 180 &error ) ) |
| 171 | 181 |
| 172 #define FT_MEM_QRENEW_ARRAY( ptr, cursz, newsz ) \ | 182 #define FT_MEM_ALLOC_MULT( ptr, count, item_size ) \ |
| 173 FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, sizeof ( *(ptr) ), \ | 183 FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \ |
| 174 (cursz), (newsz), \ | 184 (FT_Long)(item_size), \ |
| 175 (ptr), &error ) ) | 185 0, \ |
| 186 (FT_Long)(count), \ |
| 187 NULL, \ |
| 188 &error ) ) |
| 176 | 189 |
| 177 #define FT_MEM_ALLOC_MULT( ptr, count, item_size ) \ | 190 #define FT_MEM_REALLOC_MULT( ptr, oldcnt, newcnt, itmsz ) \ |
| 178 FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, (item_size), \ | 191 FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \ |
| 179 0, (count), \ | 192 (FT_Long)(itmsz), \ |
| 180 NULL, &error ) ) | 193 (FT_Long)(oldcnt), \ |
| 194 (FT_Long)(newcnt), \ |
| 195 (ptr), \ |
| 196 &error ) ) |
| 181 | 197 |
| 182 #define FT_MEM_REALLOC_MULT( ptr, oldcnt, newcnt, itmsz ) \ | 198 #define FT_MEM_QALLOC_MULT( ptr, count, item_size ) \ |
| 183 FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, (itmsz), \ | 199 FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, \ |
| 184 (oldcnt), (newcnt), \ | 200 (FT_Long)(item_size), \ |
| 185 (ptr), &error ) ) | 201 0, \ |
| 202 (FT_Long)(count), \ |
| 203 NULL, \ |
| 204 &error ) ) |
| 186 | 205 |
| 187 #define FT_MEM_QALLOC_MULT( ptr, count, item_size ) \ | 206 #define FT_MEM_QREALLOC_MULT( ptr, oldcnt, newcnt, itmsz) \ |
| 188 FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, (item_size), \ | 207 FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, \ |
| 189 0, (count), \ | 208 (FT_Long)(itmsz), \ |
| 190 NULL, &error ) ) | 209 (FT_Long)(oldcnt), \ |
| 191 | 210 (FT_Long)(newcnt), \ |
| 192 #define FT_MEM_QREALLOC_MULT( ptr, oldcnt, newcnt, itmsz) \ | 211 (ptr), \ |
| 193 FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, (itmsz), \ | 212 &error ) ) |
| 194 (oldcnt), (newcnt), \ | |
| 195 (ptr), &error ) ) | |
| 196 | 213 |
| 197 | 214 |
| 198 #define FT_MEM_SET_ERROR( cond ) ( (cond), error != 0 ) | 215 #define FT_MEM_SET_ERROR( cond ) ( (cond), error != 0 ) |
| 199 | 216 |
| 200 | 217 |
| 201 #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 ) |
| 202 | 219 |
| 203 #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 ) |
| 204 | 221 |
| 205 #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 ) |
| (...skipping 23 matching lines...) Expand all Loading... |
| 229 | 246 |
| 230 #define FT_ARRAY_CHECK( ptr, count ) ( (count) <= FT_ARRAY_MAX( ptr ) ) | 247 #define FT_ARRAY_CHECK( ptr, count ) ( (count) <= FT_ARRAY_MAX( ptr ) ) |
| 231 | 248 |
| 232 | 249 |
| 233 /*************************************************************************/ | 250 /*************************************************************************/ |
| 234 /* */ | 251 /* */ |
| 235 /* The following functions macros expect that their pointer argument is */ | 252 /* The following functions macros expect that their pointer argument is */ |
| 236 /* _typed_ in order to automatically compute array element sizes. */ | 253 /* _typed_ in order to automatically compute array element sizes. */ |
| 237 /* */ | 254 /* */ |
| 238 | 255 |
| 239 #define FT_MEM_NEW_ARRAY( ptr, count ) \ | 256 #define FT_MEM_NEW_ARRAY( ptr, count ) \ |
| 240 FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, sizeof ( *(ptr) ), \ | 257 FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \ |
| 241 0, (count), \ | 258 sizeof ( *(ptr) ), \ |
| 242 NULL, &error ) ) | 259 0, \ |
| 260 (FT_Long)(count), \ |
| 261 NULL, \ |
| 262 &error ) ) |
| 243 | 263 |
| 244 #define FT_MEM_RENEW_ARRAY( ptr, cursz, newsz ) \ | 264 #define FT_MEM_RENEW_ARRAY( ptr, cursz, newsz ) \ |
| 245 FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, sizeof ( *(ptr) ), \ | 265 FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \ |
| 246 (cursz), (newsz), \ | 266 sizeof ( *(ptr) ), \ |
| 247 (ptr), &error ) ) | 267 (FT_Long)(cursz), \ |
| 268 (FT_Long)(newsz), \ |
| 269 (ptr), \ |
| 270 &error ) ) |
| 248 | 271 |
| 249 #define FT_MEM_QNEW_ARRAY( ptr, count ) \ | 272 #define FT_MEM_QNEW_ARRAY( ptr, count ) \ |
| 250 FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, sizeof ( *(ptr) ), \ | 273 FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, \ |
| 251 0, (count), \ | 274 sizeof ( *(ptr) ), \ |
| 252 NULL, &error ) ) | 275 0, \ |
| 276 (FT_Long)(count), \ |
| 277 NULL, \ |
| 278 &error ) ) |
| 253 | 279 |
| 254 #define FT_MEM_QRENEW_ARRAY( ptr, cursz, newsz ) \ | 280 #define FT_MEM_QRENEW_ARRAY( ptr, cursz, newsz ) \ |
| 255 FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, sizeof ( *(ptr) ), \ | 281 FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, \ |
| 256 (cursz), (newsz), \ | 282 sizeof ( *(ptr) ), \ |
| 257 (ptr), &error ) ) | 283 (FT_Long)(cursz), \ |
| 258 | 284 (FT_Long)(newsz), \ |
| 285 (ptr), \ |
| 286 &error ) ) |
| 259 | 287 |
| 260 #define FT_ALLOC( ptr, size ) \ | 288 #define FT_ALLOC( ptr, size ) \ |
| 261 FT_MEM_SET_ERROR( FT_MEM_ALLOC( ptr, size ) ) | 289 FT_MEM_SET_ERROR( FT_MEM_ALLOC( ptr, size ) ) |
| 262 | 290 |
| 263 #define FT_REALLOC( ptr, cursz, newsz ) \ | 291 #define FT_REALLOC( ptr, cursz, newsz ) \ |
| 264 FT_MEM_SET_ERROR( FT_MEM_REALLOC( ptr, cursz, newsz ) ) | 292 FT_MEM_SET_ERROR( FT_MEM_REALLOC( ptr, cursz, newsz ) ) |
| 265 | 293 |
| 266 #define FT_ALLOC_MULT( ptr, count, item_size ) \ | 294 #define FT_ALLOC_MULT( ptr, count, item_size ) \ |
| 267 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 ) ) |
| 268 | 296 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 296 #define FT_QNEW( ptr ) \ | 324 #define FT_QNEW( ptr ) \ |
| 297 FT_MEM_SET_ERROR( FT_MEM_QNEW( ptr ) ) | 325 FT_MEM_SET_ERROR( FT_MEM_QNEW( ptr ) ) |
| 298 | 326 |
| 299 #define FT_QNEW_ARRAY( ptr, count ) \ | 327 #define FT_QNEW_ARRAY( ptr, count ) \ |
| 300 FT_MEM_SET_ERROR( FT_MEM_NEW_ARRAY( ptr, count ) ) | 328 FT_MEM_SET_ERROR( FT_MEM_NEW_ARRAY( ptr, count ) ) |
| 301 | 329 |
| 302 #define FT_QRENEW_ARRAY( ptr, curcnt, newcnt ) \ | 330 #define FT_QRENEW_ARRAY( ptr, curcnt, newcnt ) \ |
| 303 FT_MEM_SET_ERROR( FT_MEM_RENEW_ARRAY( ptr, curcnt, newcnt ) ) | 331 FT_MEM_SET_ERROR( FT_MEM_RENEW_ARRAY( ptr, curcnt, newcnt ) ) |
| 304 | 332 |
| 305 | 333 |
| 306 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS | |
| 307 | |
| 308 FT_BASE( FT_Error ) | |
| 309 FT_Alloc( FT_Memory memory, | |
| 310 FT_Long size, | |
| 311 void* *P ); | |
| 312 | |
| 313 FT_BASE( FT_Error ) | |
| 314 FT_QAlloc( FT_Memory memory, | |
| 315 FT_Long size, | |
| 316 void* *p ); | |
| 317 | |
| 318 FT_BASE( FT_Error ) | |
| 319 FT_Realloc( FT_Memory memory, | |
| 320 FT_Long current, | |
| 321 FT_Long size, | |
| 322 void* *P ); | |
| 323 | |
| 324 FT_BASE( FT_Error ) | |
| 325 FT_QRealloc( FT_Memory memory, | |
| 326 FT_Long current, | |
| 327 FT_Long size, | |
| 328 void* *p ); | |
| 329 | |
| 330 FT_BASE( void ) | |
| 331 FT_Free( FT_Memory memory, | |
| 332 void* *P ); | |
| 333 | |
| 334 #endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ | |
| 335 | |
| 336 | |
| 337 FT_BASE( FT_Pointer ) | 334 FT_BASE( FT_Pointer ) |
| 338 ft_mem_strdup( FT_Memory memory, | 335 ft_mem_strdup( FT_Memory memory, |
| 339 const char* str, | 336 const char* str, |
| 340 FT_Error *p_error ); | 337 FT_Error *p_error ); |
| 341 | 338 |
| 342 FT_BASE( FT_Pointer ) | 339 FT_BASE( FT_Pointer ) |
| 343 ft_mem_dup( FT_Memory memory, | 340 ft_mem_dup( FT_Memory memory, |
| 344 const void* address, | 341 const void* address, |
| 345 FT_ULong size, | 342 FT_ULong size, |
| 346 FT_Error *p_error ); | 343 FT_Error *p_error ); |
| 347 | 344 |
| 345 |
| 348 #define FT_MEM_STRDUP( dst, str ) \ | 346 #define FT_MEM_STRDUP( dst, str ) \ |
| 349 (dst) = (char*)ft_mem_strdup( memory, (const char*)(str), &error ) | 347 (dst) = (char*)ft_mem_strdup( memory, (const char*)(str), &error ) |
| 350 | 348 |
| 351 #define FT_STRDUP( dst, str ) \ | 349 #define FT_STRDUP( dst, str ) \ |
| 352 FT_MEM_SET_ERROR( FT_MEM_STRDUP( dst, str ) ) | 350 FT_MEM_SET_ERROR( FT_MEM_STRDUP( dst, str ) ) |
| 353 | 351 |
| 354 #define FT_MEM_DUP( dst, address, size ) \ | 352 #define FT_MEM_DUP( dst, address, size ) \ |
| 355 (dst) = ft_mem_dup( memory, (address), (FT_ULong)(size), &error ) | 353 (dst) = ft_mem_dup( memory, (address), (FT_ULong)(size), &error ) |
| 356 | 354 |
| 357 #define FT_DUP( dst, address, size ) \ | 355 #define FT_DUP( dst, address, size ) \ |
| (...skipping 13 matching lines...) Expand all Loading... |
| 371 | 369 |
| 372 /* */ | 370 /* */ |
| 373 | 371 |
| 374 | 372 |
| 375 FT_END_HEADER | 373 FT_END_HEADER |
| 376 | 374 |
| 377 #endif /* __FTMEMORY_H__ */ | 375 #endif /* __FTMEMORY_H__ */ |
| 378 | 376 |
| 379 | 377 |
| 380 /* END */ | 378 /* END */ |
| OLD | NEW |