From 04b7ccfd87d802e6b9a22b86c8d098979164b8ba Mon Sep 17 00:00:00 2001 From: Fox Caminiti Date: Mon, 15 Aug 2022 23:03:30 -0400 Subject: undo started --- memory.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'memory.cpp') 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; } -- cgit v1.2.3