diff --git a/Engine/src/delta/core/FreeListAllocator.cpp b/Engine/src/delta/core/FreeListAllocator.cpp index 3a07bc0..5b8c3b4 100644 --- a/Engine/src/delta/core/FreeListAllocator.cpp +++ b/Engine/src/delta/core/FreeListAllocator.cpp @@ -31,10 +31,12 @@ DLT_FORCE_INLINE void* AllocatePageForBucket(FreeListAllocator* allocator, uint3 uint64_t numChunks = allocator->pageSize / size; uint8_t* walker = static_cast(rawPage); + // first step Node* head = reinterpret_cast(walker); Node* current = head; - for (uint32_t i = 0; i < numChunks; i++) + // next n - 1 steps + for (uint32_t i = 0; i < numChunks - 2; i++) { walker += size; Node* next = reinterpret_cast(walker); @@ -42,8 +44,9 @@ DLT_FORCE_INLINE void* AllocatePageForBucket(FreeListAllocator* allocator, uint3 current = next; } - current->next = nullptr; - return head; + walker += size; + Node* next = reinterpret_cast(walker); + return next; } void delta::core::FreeList_Init(FreeListAllocator* allocator, MemoryState* memState) @@ -76,3 +79,13 @@ void* delta::core::FreeList_Allocate(FreeListAllocator* allocator, uint64_t size return MemoryManager::AllocatePageLockFree(allocator->memState); } + +void delta::core::FreeList_Free(FreeListAllocator* allocator, void* ptr) +{ + +} + +void delta::core::FreeList_Destroy(FreeListAllocator* allocator) +{ + +} diff --git a/Engine/src/delta/core/FreeListAllocator.h b/Engine/src/delta/core/FreeListAllocator.h index 8c115b3..604144a 100644 --- a/Engine/src/delta/core/FreeListAllocator.h +++ b/Engine/src/delta/core/FreeListAllocator.h @@ -38,4 +38,6 @@ namespace delta::core void FreeList_Init(FreeListAllocator* allocator, MemoryManager::MemoryState* memState); void* FreeList_Allocate(FreeListAllocator* allocator, uint64_t size, uint64_t alignment); + void FreeList_Free(FreeListAllocator* allocator, void* ptr); + void FreeList_Destroy(FreeListAllocator* allocator); }