diff options
Diffstat (limited to 'memory.cpp')
-rw-r--r-- | memory.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -25,6 +25,25 @@ AllocateMemory(memory *Memory, uint64 Size, memory_table_list TableName) { return Address; } +// Returns the address and THEN advances +static void* +Memory_Advance(memory *Memory, uint64 Size, memory_table_list TableName) { + return AllocateMemory(Memory, Size, TableName); +} + +// Rewinds and THEN returns the address +static void* +Memory_Rewind(memory *Memory, uint64 Size, memory_table_list TableName) { + void *Address; + memory_table *Table = &Memory->Slot[TableName]; + if (Table->CurrentPosition - Size < 0) { + return NULL; + } + Table->CurrentPosition -= Size; + Address = (ptrsize *)((uint8 *)Table->Address + Table->CurrentPosition); + return Address; +} + // Returns 0-1 range wherever Pointer is in relation to StartingPointer to Size*Amount. static real32 Memory_NormalizedPosition(void *StartingPointer, uint32 Amount, uint32 Size, void *Pointer) |