|
Ruby 4.1.0dev (2026-03-07 revision fd9448bc87a51482564ac997e0c1c6e5f36e7927)
|
A bump allocator for the prism parser. More...
#include "prism/defines.h"#include <stddef.h>#include <stdio.h>#include <stdlib.h>#include <string.h>

Go to the source code of this file.
Data Structures | |
| struct | pm_arena_block |
| A single block of memory in the arena. More... | |
| struct | pm_arena_t |
| A bump allocator. More... | |
Typedefs | |
| typedef struct pm_arena_block | pm_arena_block_t |
| A single block of memory in the arena. | |
Functions | |
| void * | pm_arena_alloc (pm_arena_t *arena, size_t size, size_t alignment) |
| Allocate memory from the arena. | |
| void * | pm_arena_zalloc (pm_arena_t *arena, size_t size, size_t alignment) |
| Allocate zero-initialized memory from the arena. | |
| void * | pm_arena_memdup (pm_arena_t *arena, const void *src, size_t size, size_t alignment) |
| Allocate memory from the arena and copy the given data into it. | |
| PRISM_EXPORTED_FUNCTION void | pm_arena_free (pm_arena_t *arena) |
| Free all blocks in the arena. | |
A bump allocator for the prism parser.
Definition in file pm_arena.h.
| typedef struct pm_arena_block pm_arena_block_t |
A single block of memory in the arena.
Blocks are linked via prev pointers so they can be freed by walking the chain.
| void * pm_arena_alloc | ( | pm_arena_t * | arena, |
| size_t | size, | ||
| size_t | alignment | ||
| ) |
Allocate memory from the arena.
The returned memory is NOT zeroed. This function is infallible — it aborts on allocation failure.
| arena | The arena to allocate from. |
| size | The number of bytes to allocate. |
| alignment | The required alignment (must be a power of 2). |
The returned memory is NOT zeroed. This function is infallible — it aborts on allocation failure.
Definition at line 37 of file pm_arena.c.
| PRISM_EXPORTED_FUNCTION void pm_arena_free | ( | pm_arena_t * | arena | ) |
Free all blocks in the arena.
After this call, all pointers returned by pm_arena_alloc and pm_arena_zalloc are invalid.
| arena | The arena to free. |
Definition at line 95 of file pm_arena.c.
| void * pm_arena_memdup | ( | pm_arena_t * | arena, |
| const void * | src, | ||
| size_t | size, | ||
| size_t | alignment | ||
| ) |
Allocate memory from the arena and copy the given data into it.
This is a convenience wrapper around pm_arena_alloc + memcpy.
| arena | The arena to allocate from. |
| src | The source data to copy. |
| size | The number of bytes to allocate and copy. |
| alignment | The required alignment (must be a power of 2). |
Definition at line 85 of file pm_arena.c.
| void * pm_arena_zalloc | ( | pm_arena_t * | arena, |
| size_t | size, | ||
| size_t | alignment | ||
| ) |
Allocate zero-initialized memory from the arena.
This function is infallible — it aborts on allocation failure.
| arena | The arena to allocate from. |
| size | The number of bytes to allocate. |
| alignment | The required alignment (must be a power of 2). |
This function is infallible — it aborts on allocation failure.
Definition at line 75 of file pm_arena.c.