medfall

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 73c719c4e53842ed1dfc41bc68b54d83fcbd7f0a
parent 789c540825d27df0f752831bbce2e4d8d33a1c90
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Tue Sep  1 22:37:15 +0200

Add memarena_push_arena

Diffstat:
memory_arena.cc | 9+++++++++
memory_arena.h | 2++
2 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/memory_arena.cc b/memory_arena.cc @@ -18,6 +18,15 @@ u8 * memarena_push_size( MemoryArena * const arena, const size_t size, const siz return arena->memory + base_index; } +MemoryArena memarena_push_arena( MemoryArena * const arena, const size_t size ) { + u8 * const memory = memarena_push_size( arena, size ); + + MemoryArena new_arena = { }; + memarena_init( &new_arena, memory, size ); + + return new_arena; +} + void memarena_clear( MemoryArena * const arena ) { arena->used = 0; arena->num_checkpoints = 0; diff --git a/memory_arena.h b/memory_arena.h @@ -22,6 +22,8 @@ u8 * memarena_push_size( MemoryArena * const arena, const size_t size, const siz #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__ ) ) +MemoryArena memarena_push_arena( MemoryArena * const arena, const size_t size ); + void memarena_clear( MemoryArena * const arena ); MemoryArenaCheckpoint memarena_checkpoint( MemoryArena * const arena );