blob: 5bc4c691ec43c3a0ed30b67d8e0afb4c40bf61fc (
plain) (
blame)
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
32
33
34
35
36
37
|
#pragma once
#ifndef ARENA_H_
#define ARENA_H_
#include <stddef.h>
/**
* Create arena holding up to `arena_size` bytes.
* Return 0 on success, <0 on failure.
*/
int
ar_setup(size_t arena_size);
/**
* Allocate `object_size` bytes from the arena.
* Return NULL on failure.
*/
void *
ar_alloc(size_t object_size);
/**
* Free all allocations made in the arena.
* Invalidates all pointers you may still be holding.
* The arena still exists, ready for `ar_alloc` calls.
*/
void
ar_free(void);
/**
* Destroy the arena, freeing all memory allocated in `ar_setup`.
* Invalidates all pointers you may still be holding.
*/
void
ar_cleanup(void);
#endif
|