summaryrefslogtreecommitdiff
path: root/include/lib/arena.h
blob: 9d3cb385cf157a8864fbb19664327b14152aa266 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/**
 * @file arena.h
 * @author x221e
 * @brief linear arena-allocation without relocation
 * @description
 * This will be a linear arena allocation,
 * no free functionality exists right now.
 *
 * @todo create a larger arena structure that would hold regions
 */

#ifndef ARENA_H
#define ARENA_H

#include <stddef.h>

// 2 MiB regions
#define REGION_MAX_CAPACITY    1024*1024*2 

struct region { // or arena?
	size_t capacity;
	size_t size;
	void *end;
	void *start;
};

int region_init(struct region *r);
void *region_alloc(struct region *r, size_t b);
int region_pop(struct region *r, size_t b);

#endif