cwist
Modern C web framework with libttak runtime
Loading...
Searching...
No Matches
arena.h
Go to the documentation of this file.
1
10#ifndef __CWIST_CORE_MEM_ARENA_H__
11#define __CWIST_CORE_MEM_ARENA_H__
12
13#include <stdbool.h>
14#include <stddef.h>
15
20#define CWIST_ARENA_DEFAULT_GENERATION_BYTES (8 * 1024)
21
22typedef struct cwist_arena cwist_arena_t;
23
31cwist_arena_t *cwist_arena_create(size_t generation_bytes);
32
39void *cwist_arena_alloc(cwist_arena_t *arena, size_t size);
40
44bool cwist_arena_owns(const cwist_arena_t *arena, const void *ptr);
45
51
52#endif /* __CWIST_CORE_MEM_ARENA_H__ */
struct cwist_arena cwist_arena_t
Definition arena.h:22
void * cwist_arena_alloc(cwist_arena_t *arena, size_t size)
Bump-allocate size bytes from the active generation.
Definition arena.c:44
bool cwist_arena_owns(const cwist_arena_t *arena, const void *ptr)
Check whether ptr lies inside the active generation buffer.
Definition arena.c:54
void cwist_arena_destroy(cwist_arena_t *arena)
Retire the generation and destroy the arena, releasing every allocation made from it at once.
Definition arena.c:60
cwist_arena_t * cwist_arena_create(size_t generation_bytes)
Create an arena backed by a recycled thread-local generation buffer.
Definition arena.c:32