summaryrefslogtreecommitdiff
path: root/memory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'memory.cpp')
-rw-r--r--memory.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/memory.cpp b/memory.cpp
index dd581b7..7c08f91 100644
--- a/memory.cpp
+++ b/memory.cpp
@@ -1,12 +1,18 @@
+
static 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 *)((uint8 *)GlobalMemory->Address + GlobalMemory->CurrentPosition);
+ Table->Address = (ptrsize *)((uint8 *)GlobalMemory->Address + GlobalMemory->CurrentPosition);
Table->Size = Size;
GlobalMemory->CurrentPosition += Size;
}
+// NOTE(fox): Currently memory acts like simple stack that can only grow forwards.
+// Undos/deletes create "holes." Once someone undos/deletes enough to trigger
+// the limit or we start caring more about space, I'll revamp the system to
+// keep track of free holes and allow those to be returned.
+
static void*
AllocateMemory(memory *Memory, uint64 Size, memory_table_list TableName) {
void *Address;
@@ -14,7 +20,7 @@ AllocateMemory(memory *Memory, uint64 Size, memory_table_list TableName) {
if (Table->CurrentPosition + Size > Table->Size) {
return NULL;
}
- Address = (uint64 *)((uint8 *)Table->Address + Table->CurrentPosition);
+ Address = (ptrsize *)((uint8 *)Table->Address + Table->CurrentPosition);
Table->CurrentPosition += Size;
return Address;
}