diff options
author | Fox Caminiti <fox@foxcam.net> | 2022-08-15 23:03:30 -0400 |
---|---|---|
committer | Fox Caminiti <fox@foxcam.net> | 2022-08-15 23:03:30 -0400 |
commit | 04b7ccfd87d802e6b9a22b86c8d098979164b8ba (patch) | |
tree | b155fbfb7d4b494bae79073161dfeb36dc8edc49 /memory.cpp | |
parent | 67898c6505c9180b5a5a31457f11d29b41fa91ba (diff) |
undo started
Diffstat (limited to 'memory.cpp')
-rw-r--r-- | memory.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -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; } |