Add arena allocator library
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m44s
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m44s
This commit is contained in:
25
libarena/arena.h
Normal file
25
libarena/arena.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef _LIBARENA_ARENA_H
|
||||
#define _LIBARENA_ARENA_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#define ARENA_CHUNK_CAPACITY (8 * 1024)
|
||||
|
||||
struct arena_chunk {
|
||||
struct arena_chunk* next;
|
||||
size_t capacity;
|
||||
size_t size;
|
||||
uintptr_t memory[];
|
||||
};
|
||||
|
||||
struct arena {
|
||||
struct arena_chunk *begin, *end;
|
||||
};
|
||||
|
||||
void arena_reset (struct arena* arena);
|
||||
|
||||
void arena_destroy (struct arena* arena);
|
||||
|
||||
void* arena_malloc (struct arena* arena, size_t size);
|
||||
|
||||
#endif // _LIBARENA_ARENA_H
|
||||
Reference in New Issue
Block a user