Newer
Older
tree-os / src / kernel / memory / alloc.c
#include <alloc.h>
#include <paging.h>
#include <stdint.h>
#include <stdio.h>
#include <task.h>

void *mallocTaskAligned(uintptr_t size, uint8_t alignment, Task *task) {
    // todo: do this nicer : have different 'buckets' for different allocation
    // sizes
    return getPage();
}

void *mallocTask(uintptr_t size, Task *task) {
    return mallocTaskAligned(size, 0, task);
}

void *malloc(uintptr_t size) { return mallocTaskAligned(size, 0, currentTask); }

void *mallocAligned(uintptr_t size, uint8_t alignment) {
    return mallocTaskAligned(size, alignment, currentTask);
}

void free(void *location) { freePage(location); }

void freeTaskAllocations(Task *task) {
    // todo
}