summaryrefslogtreecommitdiff
path: root/code/amr_memory.h
diff options
context:
space:
mode:
authortalha <talha@talhaamir.xyz>2023-08-30 22:58:18 +0500
committertalha <talha@talhaamir.xyz>2023-08-30 22:58:18 +0500
commit66e84eabf70a11d91abbbe8777b1746573a51bae (patch)
tree3cca9403bde6a97889353b439ec84af5c661d988 /code/amr_memory.h
parentd980dcd2b66e4879989ce18291d044d5a4ffc902 (diff)
Refactored files:
- moved memory arenas to memory files - replaced r32 and r64 with f32 and f64 - prefixing internal libs with amr_
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