Newer
Older
tree-os / src / include / alloc.h
#ifndef ALLOC_H
#define ALLOC_H

#include <stdint.h>
#include <task.h>

typedef struct MemoryBlock {
    struct MemoryBlock *last;
    struct MemoryBlock *next;
    uint32_t size;
    Task *task;
} MemoryBlock;

extern void initMemoryAllocation(uintptr_t kernelEnd);
extern void *malloc(uintptr_t size);
extern void *mallocAligned(uintptr_t size, uint8_t alignment);
extern void *mallocTask(uintptr_t size, Task *task);
extern void free(void *location);
extern void printMemoryStack();
extern void freeTaskAllocations(Task *task);
extern Task *getCurrentTask();

#endif