|
memory_arena
|
Arena snapshot input/output operations (save/load). More...
Include dependency graph for arena_io.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Data Structures | |
| struct | s_arena_snapshot_header |
| Header structure prepended to saved arena snapshots. More... | |
Macros | |
| #define | ARENA_SNAPSHOT_MAGIC "ARENASNAP" |
| Magic string identifying a valid arena snapshot file. | |
| #define | ARENA_SNAPSHOT_VERSION 1 |
| Version number of the snapshot file format. | |
Functions | |
| struct s_arena_snapshot_header | __attribute__ ((packed)) t_arena_snapshot_header |
| Header structure prepended to saved arena snapshots. | |
| bool | arena_load_from_file (t_arena *arena, const char *path) |
| Load arena contents from a snapshot file. | |
| bool | arena_save_to_file (const t_arena *arena, const char *path) |
| Save the current contents of an arena to a file. | |
Variables | |
| char | magic [9] |
| Magic string ("ARENASNAP\0") | |
| size_t | used |
| Number of bytes used in the arena buffer. | |
| uint32_t | version |
| Snapshot file format version. | |
Arena snapshot input/output operations (save/load).
This header declares functions to serialize and deserialize the memory contents of an arena. These operations allow arenas to be saved to disk and restored later, enabling features such as state persistence, debugging snapshots, or offline replay.
The snapshot includes a compact header (t_arena_snapshot_header) followed by the raw used memory buffer of the arena.
arena_save_to_file() writes the arena's used memory to a file.arena_load_from_file() restores the memory contents from a file into an existing arena.Definition in file arena_io.h.
| struct s_arena_snapshot_header |
Header structure prepended to saved arena snapshots.
This packed structure contains metadata about a saved arena buffer, including:
This header is written/read before the actual memory contents of the arena.
Definition at line 53 of file arena_io.h.
| Data Fields | ||
|---|---|---|
| char | magic[9] | Magic string ("ARENASNAP\0") |
| size_t | used | Number of bytes used in the arena buffer. |
| uint32_t | version | Snapshot file format version. |
| #define ARENA_SNAPSHOT_MAGIC "ARENASNAP" |
Magic string identifying a valid arena snapshot file.
Definition at line 34 of file arena_io.h.
| #define ARENA_SNAPSHOT_VERSION 1 |
Version number of the snapshot file format.
Definition at line 37 of file arena_io.h.
| struct s_arena_snapshot_header __attribute__ | ( | (packed) | ) |
Header structure prepended to saved arena snapshots.
This packed structure contains metadata about a saved arena buffer, including:
This header is written/read before the actual memory contents of the arena.
| bool arena_load_from_file | ( | t_arena * | arena, |
| const char * | path | ||
| ) |
Load arena contents from a snapshot file.
This function reads a snapshot file created with arena_save_to_file() and writes the contents into the provided arena buffer.
The arena must have been initialized with a buffer large enough to hold the restored data. The arena's internal offset will be updated accordingly.
| arena | Pointer to the arena to restore. |
| path | Path to the snapshot file. |
true on success, false on failure. Definition at line 255 of file arena_io.c.
References ARENA_SNAPSHOT_MAGIC, and ARENA_SNAPSHOT_VERSION.
| bool arena_save_to_file | ( | const t_arena * | arena, |
| const char * | path | ||
| ) |
Save the current contents of an arena to a file.
This function writes a snapshot of the arena to the specified file path. The snapshot includes a header and all memory up to arena->offset.
| arena | Pointer to the arena to save. |
| path | Path to the output file. |
true on success, false on failure. Definition at line 161 of file arena_io.c.
References ARENA_LOCK, ARENA_SNAPSHOT_MAGIC, ARENA_SNAPSHOT_VERSION, ARENA_UNLOCK, and used.
| char magic[9] |
Magic string ("ARENASNAP\0")
Definition at line 0 of file arena_io.h.
| size_t used |
Number of bytes used in the arena buffer.
Definition at line 2 of file arena_io.h.
| uint32_t version |
Snapshot file format version.
Definition at line 1 of file arena_io.h.