medfall

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

commit c540dec71a67e06683fc0fb00b6d691897ee367e
parent cf4fe196d977cbf3dd99c1f187b6dade14040781
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Sat Nov  5 13:28:00 +0200

Const madness

Diffstat:
memory_arena.cc | 14+++++++-------
memory_arena.h | 12++++++------
2 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/memory_arena.cc b/memory_arena.cc @@ -1,13 +1,13 @@ #include "intrinsics.h" #include "memory_arena.h" -void memarena_init( MemoryArena * const arena, u8 * const memory, const size_t size ) { +void memarena_init( MemoryArena * arena, u8 * memory, size_t size ) { arena->memory = memory; arena->size = size; arena->used = 0; } -u8 * memarena_push_size( MemoryArena * const arena, const size_t size, const uptr alignment ) { +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 ); @@ -19,8 +19,8 @@ u8 * memarena_push_size( MemoryArena * const arena, const size_t size, const upt return ( u8 * ) aligned_addr; } -MemoryArena memarena_push_arena( MemoryArena * const arena, const size_t size ) { - u8 * const memory = memarena_push_size( arena, size ); +MemoryArena memarena_push_arena( MemoryArena * arena, size_t size ) { + u8 * memory = memarena_push_size( arena, size ); MemoryArena new_arena = { }; memarena_init( &new_arena, memory, size ); @@ -28,12 +28,12 @@ MemoryArena memarena_push_arena( MemoryArena * const arena, const size_t size ) return new_arena; } -void memarena_clear( MemoryArena * const arena ) { +void memarena_clear( MemoryArena * arena ) { arena->used = 0; arena->num_checkpoints = 0; } -MemoryArenaCheckpoint memarena_checkpoint( MemoryArena * const arena ) { +MemoryArenaCheckpoint memarena_checkpoint( MemoryArena * arena ) { MemoryArenaCheckpoint cp = { }; // cp.arena = arena; cp.used = arena->used; @@ -42,7 +42,7 @@ MemoryArenaCheckpoint memarena_checkpoint( MemoryArena * const arena ) { return cp; } -void memarena_restore( MemoryArena * arena, MemoryArenaCheckpoint * const cp ) { +void memarena_restore( MemoryArena * arena, MemoryArenaCheckpoint * cp ) { assert( arena->num_checkpoints > 0 ); assert( !cp->restored ); assert( arena->used >= cp->used ); diff --git a/memory_arena.h b/memory_arena.h @@ -25,9 +25,9 @@ struct MemoryArenaAutoCheckpoint { ~MemoryArenaAutoCheckpoint(); }; -void memarena_init( MemoryArena * const arena, u8 * const memory, const size_t size ); +void memarena_init( MemoryArena * arena, u8 * memory, size_t size ); -u8 * memarena_push_size( MemoryArena * const arena, const size_t size, const uptr alignment = 16 ); +u8 * memarena_push_size( MemoryArena * arena, size_t size, uptr alignment = 16 ); #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__ ) ) @@ -36,12 +36,12 @@ u8 * memarena_push_size( MemoryArena * const arena, const size_t size, const upt #define memarena_push_array2d( arena, type, width, height, ... ) \ array2d< type >( ( ( type * ) memarena_push_size( arena, sizeof( type ) * width * height, ##__VA_ARGS__ ) ), width, height ) -MemoryArena memarena_push_arena( MemoryArena * const arena, const size_t size ); +MemoryArena memarena_push_arena( MemoryArena * arena, size_t size ); -void memarena_clear( MemoryArena * const arena ); +void memarena_clear( MemoryArena * arena ); -MemoryArenaCheckpoint memarena_checkpoint( MemoryArena * const arena ); -void memarena_restore( MemoryArena * arena, MemoryArenaCheckpoint * const cp ); +MemoryArenaCheckpoint memarena_checkpoint( MemoryArena * arena ); +void memarena_restore( MemoryArena * arena, MemoryArenaCheckpoint * cp ); #define MEMARENA_SCOPED_CHECKPOINT( arena ) MemoryArenaAutoCheckpoint CONCAT( mem_cp, __COUNTER__ )( arena, memarena_checkpoint( arena ) );