medfall

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

commit 03cc52c5115283d0b863239ae60e0d007621e8c6
parent 73aa359e5310299b9307a37320e05c6f4eaea635
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Thu Dec 29 15:50:29 +0200

Memory arena warnings

Diffstat:
memory_arena.cc | 18+++++++++---------
memory_arena.h | 8++++----
2 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/memory_arena.cc b/memory_arena.cc @@ -11,8 +11,8 @@ u8 * memarena_push_size( MemoryArena * arena, size_t size, uptr alignment ) { uptr mem_addr = ( uptr ) arena->memory; uptr aligned_addr = align_arbitrary( mem_addr + arena->used, alignment ); uptr new_used = size + ( aligned_addr - mem_addr ); - assert( new_used <= arena->size ); - assert( new_used >= arena->used ); + ASSERT( new_used <= arena->size ); + ASSERT( new_used >= arena->used ); arena->used = new_used; @@ -43,20 +43,20 @@ MemoryArenaCheckpoint memarena_checkpoint( MemoryArena * arena ) { } void memarena_restore( MemoryArena * arena, MemoryArenaCheckpoint * cp ) { - assert( arena->num_checkpoints > 0 ); - assert( !cp->restored ); - assert( arena->used >= cp->used ); + ASSERT( arena->num_checkpoints > 0 ); + ASSERT( !cp->restored ); + ASSERT( arena->used >= cp->used ); arena->used = cp->used; arena->num_checkpoints--; cp->restored = true; } -MemoryArenaAutoCheckpoint::MemoryArenaAutoCheckpoint( MemoryArena * arena, MemoryArenaCheckpoint cp ) { - this->arena = arena; - this->cp = cp; +MemoryArenaAutoCheckpoint::MemoryArenaAutoCheckpoint( MemoryArena * a, MemoryArenaCheckpoint cp ) { + arena = a; + checkpoint = cp; } MemoryArenaAutoCheckpoint::~MemoryArenaAutoCheckpoint() { - memarena_restore( arena, &cp ); + memarena_restore( arena, &checkpoint ); } diff --git a/memory_arena.h b/memory_arena.h @@ -17,11 +17,11 @@ struct MemoryArenaCheckpoint { }; struct MemoryArenaAutoCheckpoint { - MemoryArena * arena; - MemoryArenaCheckpoint cp; - - MemoryArenaAutoCheckpoint( MemoryArena * arena, MemoryArenaCheckpoint cp ); + MemoryArenaAutoCheckpoint( MemoryArena * a, MemoryArenaCheckpoint cp ); ~MemoryArenaAutoCheckpoint(); + + MemoryArena * arena; + MemoryArenaCheckpoint checkpoint; }; void memarena_init( MemoryArena * arena, u8 * memory, size_t size );