tape-kernel 1.0
a modular modern independent kernel
Loading...
Searching...
No Matches
heap.h
Go to the documentation of this file.
1#ifndef HEAP_H
2#define HEAP_H
3
4#include "../lib/types.h"
5
6/**
7 * @brief the arena_t type
8 *
9 * arena_t is made up of start, current, size, and next
10 * @param start, is the start of the arena
11 * @param current, is the current location of the arena
12 * @param size, is the total arena size
13 * @param next, is the linked list of child arenas
14 *
15 * @see hinit(), anew(), res(), alc()
16*/
17typedef struct { //arena type
18 uint32_t *start; //the heaps start
19 uint32_t *current; //the current loc of the heap
20 uint32_t size; //the total size
21 void *next; //the linked list for the arenas
22} arena_t;
23
24#define hinit __hinit
25#define alc __alc
26#define res __res
27#define anew __anew
28
29void __hinit(arena_t *heap, void *start, uint32_t size); //heap init
30void *__alc(arena_t *heap, uint32_t size); //alloc
31void __res(arena_t *heap); //reset
32arena_t *__anew(arena_t *parent, uint32_t size);
33
34#endif
arena_t * __anew(arena_t *parent, uint32_t size)
creates a child arena under a central heap
Definition heap.c:105
void __hinit(arena_t *heap, void *start, uint32_t size)
initializes a central heap rather then child arena
Definition heap.c:30
void * __alc(arena_t *heap, uint32_t size)
allocates memory to a heap
Definition heap.c:51
void __res(arena_t *heap)
resets a arena or heap by setting current to start and overriding data
Definition heap.c:82
the arena_t type
Definition heap.h:17
uint32_t * start
Definition heap.h:18
uint32_t size
Definition heap.h:20
void * next
Definition heap.h:21
uint32_t * current
Definition heap.h:19
unsigned int uint32_t
Definition types.h:30