summaryrefslogtreecommitdiff
path: root/memory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'memory.cpp')
-rw-r--r--memory.cpp33
1 files changed, 30 insertions, 3 deletions
diff --git a/memory.cpp b/memory.cpp
index 27ac266..f502eb2 100644
--- a/memory.cpp
+++ b/memory.cpp
@@ -30,7 +30,6 @@ Memory_Block_AllocateNew(memory *Memory, memory_table_list TableName)
Index++;
}
Memory_Zero(Address_Playhead, Table->Block_ElementSize);
- *Address_Playhead = 1;
return Index;
}
@@ -41,7 +40,6 @@ Memory_Block_AddressAtIndex(memory *Memory, memory_table_list TableName, uint32
memory_table *Table = &Memory->Slot[TableName];
Assert(Table->Block_ElementSize != 0);
uint8 *Address = (uint8 *)Table->Address + (Table->Block_ElementSize * Index);
- Assert(*Address == 1);
return (void *)Address;
}
@@ -49,7 +47,36 @@ static void *
Memory_Block_AllocateAddress(memory *Memory, memory_table_list TableName)
{
uint16 FileIndex = Memory_Block_AllocateNew(Memory, TableName);
- return Memory_Block_AddressAtIndex(Memory, F_File, FileIndex);
+ return Memory_Block_AddressAtIndex(Memory, TableName, FileIndex);
+}
+
+static void *
+Memory_PushScratch(memory *Memory, uint64 Size) {
+ memory_table *Table = &Memory->Slot[B_ScratchSpace];
+ uint8 *Address = ((uint8 *)Table->Address + Memory->ScratchPos);
+ Memory->ScratchPos += Size;
+#if DEBUG
+ Debug.ScratchSize[Debug.ScratchState] = Size;
+ Debug.ScratchState++;
+#endif
+ return (void *)Address;
+}
+
+static void
+Memory_PopScratch(memory *Memory, uint64 Size) {
+ memory_table *Table = &Memory->Slot[B_ScratchSpace];
+ Memory->ScratchPos -= Size;
+#if DEBUG
+ Debug.ScratchState--;
+ Assert(Debug.ScratchSize[Debug.ScratchState] == Size);
+#endif
+}
+
+static void *
+Memory_AddressAtOffset(memory *Memory, memory_table_list TableName, uint64 Offset)
+{
+ memory_table *Table = &Memory->Slot[TableName];
+ return (void *)((uint8 *)Table->Address + Offset);
}
#if 0