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

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

typedef enum MemoryState { FREE = 0, IN_USE = 1 } MemoryState;

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

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

#endif