287 } |
287 } |
288 }; |
288 }; |
289 |
289 |
290 // One of the following macros must be used when allocating |
290 // One of the following macros must be used when allocating |
291 // an array or object from an arena |
291 // an array or object from an arena |
292 #define NEW_ARENA_ARRAY(arena, type, size)\ |
292 #define NEW_ARENA_ARRAY(arena, type, size) \ |
293 (type*) arena->Amalloc((size) * sizeof(type)) |
293 (type*) (arena)->Amalloc((size) * sizeof(type)) |
294 |
294 |
295 #define REALLOC_ARENA_ARRAY(arena, type, old, old_size, new_size)\ |
295 #define REALLOC_ARENA_ARRAY(arena, type, old, old_size, new_size) \ |
296 (type*) arena->Arealloc((char*)(old), (old_size) * sizeof(type), (new_size) * sizeof(type) ) |
296 (type*) (arena)->Arealloc((char*)(old), (old_size) * sizeof(type), \ |
297 |
297 (new_size) * sizeof(type) ) |
298 #define FREE_ARENA_ARRAY(arena, type, old, size)\ |
298 |
299 arena->Afree((char*)(old), (size) * sizeof(type)) |
299 #define FREE_ARENA_ARRAY(arena, type, old, size) \ |
300 |
300 (arena)->Afree((char*)(old), (size) * sizeof(type)) |
301 #define NEW_ARENA_OBJ(arena, type)\ |
301 |
|
302 #define NEW_ARENA_OBJ(arena, type) \ |
302 NEW_ARENA_ARRAY(arena, type, 1) |
303 NEW_ARENA_ARRAY(arena, type, 1) |
303 |
304 |
304 |
305 |
305 //%note allocation_1 |
306 //%note allocation_1 |
306 extern char* resource_allocate_bytes(size_t size); |
307 extern char* resource_allocate_bytes(size_t size); |