Heap: Count the heap blocks' size in the size required for an allocation
This commit is contained in:
parent
0edabd6d87
commit
6c3024d4ee
@ -176,7 +176,7 @@ Result<void*> kmalloc(usize size)
|
||||
|
||||
if (!heap_start)
|
||||
{
|
||||
const usize pages = get_pages_for_allocation(size);
|
||||
const usize pages = get_pages_for_allocation(size + sizeof(HeapBlock));
|
||||
HeapBlock* const block = TRY(allocate_pages(pages));
|
||||
|
||||
block->full_size = (pages * ARCH_PAGE_SIZE) - sizeof(HeapBlock);
|
||||
@ -214,7 +214,7 @@ Result<void*> kmalloc(usize size)
|
||||
|
||||
if (!block) // No free blocks, let's allocate a new one
|
||||
{
|
||||
usize pages = get_pages_for_allocation(size);
|
||||
usize pages = get_pages_for_allocation(size + sizeof(HeapBlock));
|
||||
block = TRY(allocate_pages(pages));
|
||||
|
||||
block->full_size = (pages * ARCH_PAGE_SIZE) - sizeof(HeapBlock);
|
||||
|
Loading…
Reference in New Issue
Block a user