#ifndef AMR_MEMORY_H #define AMR_MEMORY_H #ifndef DEFAULT_ALIGNMENT #define DEFAULT_ALIGNMENT (2*sizeof(void *)) #endif typedef struct amr_DebugArena { u8 *Buffer; size_t Size; size_t CurrOffset; size_t PrevOffset; } amr_DebugArena; bool amr_IsPowerOfTwo(uintptr_t x); uintptr_t amr_AlignForward(uintptr_t ptr, size_t align); void *amr_ArenaAllocAlign(amr_DebugArena *Alloc, size_t Size, size_t Align); void amr_ArenaInit(amr_DebugArena *Alloc, void* BackingBuffer, size_t Size); void *amr_ArenaAlloc(amr_DebugArena *Alloc, size_t Size); void amr_ArenaFree(amr_DebugArena *Alloc, void *Ptr); void *amr_ArenaResizeAlign(amr_DebugArena *Alloc, void *OldMem, size_t OldSize, size_t NewSize, size_t Align); void *amr_ArenaResize(amr_DebugArena *Alloc, void *OldMem, size_t OldSize, size_t NewSize); void amr_ArenaFreeAll(amr_DebugArena *Alloc); #endif