summaryrefslogtreecommitdiff
path: root/code/amr_memory.h
diff options
context:
space:
mode:
Diffstat (limited to 'code/amr_memory.h')
-rw-r--r--code/amr_memory.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/code/amr_memory.h b/code/amr_memory.h
new file mode 100644
index 0000000..f7638b3
--- /dev/null
+++ b/code/amr_memory.h
@@ -0,0 +1,26 @@
+#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