End the _t nonsense

This commit is contained in:
2026-04-01 09:15:59 +02:00
parent e8a0a36889
commit e9b57f70b1
17 changed files with 59 additions and 59 deletions
+11 -11
View File
@@ -17,7 +17,7 @@ extern uint64_t kernel_virt_base;
uintptr_t kheap_start;
static struct heap_block_t* head = NULL;
static struct heap_block* head = NULL;
static uintptr_t end;
// Kernel root table (level 4)
@@ -55,8 +55,8 @@ void kheap_init()
end = current_addr;
// Give linked list head its properties
head = (struct heap_block_t*)kheap_start;
head->size = (end-kheap_start) - sizeof(struct heap_block_t);
head = (struct heap_block*)kheap_start;
head->size = (end-kheap_start) - sizeof(struct heap_block);
head->free = true;
head->next = NULL;
DEBUG("Kernel heap initialized, head=0x%p, size=%u bytes", head, head->size);
@@ -80,16 +80,16 @@ void* kmalloc(size_t size)
if (!size) return NULL;
size = ALIGN(size);
struct heap_block_t* curr = head;
struct heap_block* curr = head;
while (curr) {
// Is block free and big enough for us?
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* split = (struct heap_block_t*)((uintptr_t)curr + sizeof(struct heap_block_t) + size);
if (curr->size >= size + sizeof(struct heap_block) + 16) {
struct heap_block* split = (struct heap_block*)((uintptr_t)curr + sizeof(struct heap_block) + size);
split->size = curr->size - size - sizeof(struct heap_block_t);
split->size = curr->size - size - sizeof(struct heap_block);
split->free = true;
split->next = curr->next;
@@ -99,7 +99,7 @@ void* kmalloc(size_t size)
// Found a good block, we return it
curr->free = false;
return (void*)((uintptr_t)curr + sizeof(struct heap_block_t));
return (void*)((uintptr_t)curr + sizeof(struct heap_block));
}
// Continue browsing the list if nothing good was found yet
curr = curr->next;
@@ -127,11 +127,11 @@ void kfree(void* ptr)
if (!ptr) return;
// Set it free!
struct heap_block_t* block = (struct heap_block_t*)((uintptr_t)ptr - sizeof(struct heap_block_t));
struct heap_block* block = (struct heap_block*)((uintptr_t)ptr - sizeof(struct heap_block));
block->free = true;
// merge adjacent free blocks (coalescing)
struct heap_block_t* curr = head;
struct heap_block* curr = head;
while (curr && curr->next) {
if (curr->free && curr->next->free) {
curr->size += sizeof(*curr) + curr->next->size;
@@ -169,7 +169,7 @@ void* kalloc_stack()
void kheap_info()
{
uint64_t free_bytes = 0;
struct heap_block_t* curr = (struct heap_block_t*)kheap_start;
struct heap_block* curr = (struct heap_block*)kheap_start;
while (curr) {
if (curr->free == true) {