Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions Engine/src/delta/core/FreeListAllocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,22 @@ DLT_FORCE_INLINE void* AllocatePageForBucket(FreeListAllocator* allocator, uint3
uint64_t numChunks = allocator->pageSize / size;
uint8_t* walker = static_cast<uint8_t*>(rawPage);

// first step
Node* head = reinterpret_cast<Node*>(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<Node*>(walker);
current->next = next;
current = next;
}

current->next = nullptr;
return head;
walker += size;
Node* next = reinterpret_cast<Node*>(walker);
return next;
}

void delta::core::FreeList_Init(FreeListAllocator* allocator, MemoryState* memState)
Expand Down Expand Up @@ -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)
{

}
2 changes: 2 additions & 0 deletions Engine/src/delta/core/FreeListAllocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}