25 lines
609 B
C
25 lines
609 B
C
#ifndef ARENA_INCLUDED
|
|
#define ARENA_INCLUDED
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
typedef struct {
|
|
unsigned char *beg;
|
|
unsigned char *end;
|
|
} Arena;
|
|
|
|
Arena arena_new(size_t nbytes);
|
|
void arena_back(Arena *a, void *buf, size_t buf_len );
|
|
void *arena_alloc(Arena *a, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count);
|
|
void *arena_calloc(Arena *a, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count);
|
|
|
|
ptrdiff_t arena_cap(Arena *a);
|
|
int arena_can(Arena *a, size_t nbytes);
|
|
void arena_free(Arena *a);
|
|
void arena_reset(Arena *a);
|
|
void arena_print(Arena *a);
|
|
size_t arena_alignment(Arena *a);
|
|
|
|
#endif
|