summaryrefslogtreecommitdiff
path: root/memory.cpp
diff options
context:
space:
mode:
authorFox Caminiti <fox@foxcam.net>2022-07-22 20:45:08 -0400
committerFox Caminiti <fox@foxcam.net>2022-07-22 20:45:08 -0400
commitfc8040d695644aaca4596adebeca4ea1369ef630 (patch)
treeaea6979da97c43df8f03f3a2d7b421ee71bef370 /memory.cpp
first
Diffstat (limited to 'memory.cpp')
-rw-r--r--memory.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/memory.cpp b/memory.cpp
new file mode 100644
index 0000000..73d1fb4
--- /dev/null
+++ b/memory.cpp
@@ -0,0 +1,18 @@
+internal void
+InitMemoryTable(global_memory *GlobalMemory, memory *Memory, uint64 Size, memory_table_list TableName, char *Name) {
+ memory_table *Table = &Memory->Slot[TableName];
+ Table->Name = Name;
+ Table->Address = (uint64 *)GlobalMemory->Address + GlobalMemory->CurrentPosition;
+ Table->Size = Size;
+ GlobalMemory->CurrentPosition += Size;
+}
+
+internal void*
+AllocateMemory(memory *Memory, uint64 Size, memory_table_list TableName) {
+ void *Address;
+ memory_table *Table = &Memory->Slot[TableName];
+ Assert(Table->CurrentPosition + Size < Table->Size);
+ Address = (uint64 *)Table->Address + Table->CurrentPosition;
+ Table->CurrentPosition += Size;
+ return Address;
+}