|
cwist
Modern C web framework with libttak runtime
|
Request-scoped arena allocator backed by libttak arena generations. More...
#include <stdbool.h>#include <stddef.h>

Go to the source code of this file.
Macros | |
| #define | CWIST_ARENA_DEFAULT_GENERATION_BYTES (8 * 1024) |
| Default capacity of one arena generation buffer. A full HTTP/1.1 request+response pair (headers, query map, bodies, default security headers) bump-allocates ~3.5KB; spills fall back to the heap, so this only needs to cover the common case. | |
Typedefs | |
| typedef struct cwist_arena | cwist_arena_t |
Functions | |
| cwist_arena_t * | cwist_arena_create (size_t generation_bytes) |
| Create an arena backed by a recycled thread-local generation buffer. | |
| void * | cwist_arena_alloc (cwist_arena_t *arena, size_t size) |
Bump-allocate size bytes from the active generation. | |
| bool | cwist_arena_owns (const cwist_arena_t *arena, const void *ptr) |
Check whether ptr lies inside the active generation buffer. | |
| void | cwist_arena_destroy (cwist_arena_t *arena) |
| Retire the generation and destroy the arena, releasing every allocation made from it at once. | |
Request-scoped arena allocator backed by libttak arena generations.
Wraps ttak_arena_env_t / ttak_arena_generation_t so a request/response cycle can bump-allocate its fixed-size structures from a single generation buffer and release them all in one shot instead of freeing each node.
Definition in file arena.h.
| #define CWIST_ARENA_DEFAULT_GENERATION_BYTES (8 * 1024) |
| typedef struct cwist_arena cwist_arena_t |
| void * cwist_arena_alloc | ( | cwist_arena_t * | arena, |
| size_t | size | ||
| ) |
| cwist_arena_t * cwist_arena_create | ( | size_t | generation_bytes | ) |
Create an arena backed by a recycled thread-local generation buffer.
| generation_bytes | Capacity of the generation buffer (0 = default). |
Definition at line 32 of file arena.c.
References CWIST_ARENA_DEFAULT_GENERATION_BYTES.
Referenced by cwist_http_request_create(), and cwist_http_response_create().
| void cwist_arena_destroy | ( | cwist_arena_t * | arena | ) |
Retire the generation and destroy the arena, releasing every allocation made from it at once.
Definition at line 60 of file arena.c.
Referenced by cwist_http_request_create(), cwist_http_request_destroy(), cwist_http_response_create(), and cwist_http_response_destroy().
| bool cwist_arena_owns | ( | const cwist_arena_t * | arena, |
| const void * | ptr | ||
| ) |
Check whether ptr lies inside the active generation buffer.
Definition at line 54 of file arena.c.
Referenced by cwist_http_request_destroy(), and cwist_http_response_destroy().