Fix braces + init_paging args

This commit is contained in:
2026-03-11 19:58:00 +01:00
parent 9d409317e2
commit 8e2a612d88
29 changed files with 147 additions and 229 deletions

View File

@@ -33,11 +33,9 @@ void kheap_init()
uintptr_t current_addr = kheap_start;
// Map/alloc enough pages for heap (KHEAP_SIZE)
for (size_t i=0; i<heap_pages; i++)
{
for (size_t i=0; i<heap_pages; i++) {
uintptr_t phys = pmm_alloc();
if (phys == 0)
{
if (phys == 0) {
panic(NULL, "Not enough memory available to initialize kernel heap.");
}
@@ -63,15 +61,11 @@ void* kmalloc(size_t size)
struct heap_block_t* curr = head;
while (curr)
{
while (curr) {
// Is block free and big enough for us?
if (curr->free && curr->size >= size)
{
if (curr->free && curr->size >= size) {
// We split the block if it is big enough
if (curr->size >= size + sizeof(struct heap_block_t) + 16)
{
//struct heap_block_t* new_block = (struct heap_block_t*)((uintptr_t)curr + sizeof(struct heap_block_t) + size);
if (curr->size >= size + sizeof(struct heap_block_t) + 16) {
struct heap_block_t* split = (struct heap_block_t*)((uintptr_t)curr + sizeof(struct heap_block_t) + size);
split->size = curr->size - size - sizeof(struct heap_block_t);
@@ -109,10 +103,8 @@ void kfree(void* ptr)
// merge adjacent free blocks (coalescing)
struct heap_block_t* curr = head;
while (curr && curr->next)
{
if (curr->free && curr->next->free)
{
while (curr && curr->next) {
if (curr->free && curr->next->free) {
curr->size += sizeof(*curr) + curr->next->size;
curr->next = curr->next->next;
continue;