libsnobol4 1.0.2
High-performance SNOBOL4-style pattern matching library
Loading...
Searching...
No Matches
arena.h File Reference

Bump-allocated arena pool for short-lived scratch allocations (e.g. AST nodes during compilation, scan-loop temporaries). More...

#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include "snobol/snobol_attrs.h"
Include dependency graph for arena.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  snobol_arena_t

Macros

#define SNOBOL_ARENA_DEFAULT_CAPACITY   (64u * 1024u)
#define ARENA_ALLOC(a, t)

Detailed Description

Bump-allocated arena pool for short-lived scratch allocations (e.g. AST nodes during compilation, scan-loop temporaries).

The arena is owned by a single compile/search call: it is initialised once, used for many small fixed-size allocations, and reset (or discarded) when the call completes. There is no per-object free — the whole arena is released by the caller when it goes out of scope. When the arena is exhausted, callers fall back to snobol_malloc().

Definition in file arena.h.

Macro Definition Documentation

◆ ARENA_ALLOC

#define ARENA_ALLOC ( a,
t )
Value:
(t *)snobol_arena_alloc((a), sizeof(t), _Alignof(t))

Convenience: allocate an object of type t from arena a.

Definition at line 93 of file arena.h.

◆ SNOBOL_ARENA_DEFAULT_CAPACITY

#define SNOBOL_ARENA_DEFAULT_CAPACITY   (64u * 1024u)

Default arena capacity: 64 KiB covers all but pathologically large ASTs.

Definition at line 33 of file arena.h.