commit 947d2b777e1b9c6acef5e8ff84f4198074cc93dd parent 89a39f651d0f9a941e0543f743f38964cbbb8783 Author: Michael Savage <mikejsavage@gmail.com> Date: Sun Aug 16 19:14:59 +0200 Make alignment an optional argument in memarena_push_type. Add memarena_push_many Diffstat:
memory_arena.h | | | 6 | +++++- |
diff --git a/memory_arena.h b/memory_arena.h @@ -17,9 +17,13 @@ struct MemoryArenaCheckpoint { }; void memarena_init( MemoryArena * const arena, u8 * const memory, const size_t size ); + u8 * memarena_push_size( MemoryArena * const arena, const size_t size, const size_t alignment = sizeof( void * ) ); -#define memarena_push_type( arena, type ) ( ( type * ) memarena_push_size( arena, sizeof( type ), sizeof( type ) ) ) +#define memarena_push_type( arena, type, ... ) ( ( type * ) memarena_push_size( arena, sizeof( type ), ##__VA_ARGS__ ) ) +#define memarena_push_many( arena, type, count, ... ) ( ( type * ) memarena_push_size( arena, sizeof( type ) * count, ##__VA_ARGS__ ) ) + void memarena_clear( MemoryArena * const arena ); + MemoryArenaCheckpoint memarena_checkpoint( MemoryArena * const arena ); void memarena_restore( MemoryArena * arena, MemoryArenaCheckpoint * const cp );