blob: 30147c8e2687520ecd1a5c4e76429ea17645ffa3 (
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
|
#ifndef AMALGAM_ARENA_ALLOCATOR_H
#define AMALGAM_ARENA_ALLOCATOR_H
#include "defs.h"
#include "misc.h"
#include "types.h"
#include "buffer.h"
struct ArenaAllocatorNode {
char *data;
usize size;
ArenaAllocatorNode *next;
};
struct ArenaAllocator {
ArenaAllocatorNode head;
ArenaAllocatorNode *current;
Buffer/*<void*>*/ mems;
};
CHECK_RESULT int arena_allocator_node_init(ArenaAllocatorNode *self);
void arena_allocator_node_deinit(ArenaAllocatorNode *self);
CHECK_RESULT int arena_allocator_init(ArenaAllocator *self);
void arena_allocator_deinit(ArenaAllocator *self);
CHECK_RESULT int arena_allocator_alloc(ArenaAllocator *self, usize size, void **mem);
CHECK_RESULT int arena_allocator_add_mem(ArenaAllocator *self, usize *result_index);
#endif
|