memory_arena
Loading...
Searching...
No Matches
arena_io.h
Go to the documentation of this file.
27#ifndef ARENA_IO_H
28#define ARENA_IO_H
29
30#include "arena.h"
31#include <stdbool.h>
32
34#define ARENA_SNAPSHOT_MAGIC "ARENASNAP"
35
37#define ARENA_SNAPSHOT_VERSION 1
38
54{
55 char magic[9];
56 uint32_t version;
57 size_t used;
58} __attribute__((packed)) t_arena_snapshot_header;
59
60#ifdef __cplusplus
61extern "C"
62{
63#endif
64
79 bool arena_save_to_file(const t_arena* arena, const char* path);
80
98 bool arena_load_from_file(t_arena* arena, const char* path);
99
100#ifdef __cplusplus
101}
102#endif
103
104#endif // ARENA_IO_H
Core public API for the Arena memory allocator.
bool arena_save_to_file(const t_arena *arena, const char *path)
Save the current contents of an arena to a file.
Definition arena_io.c:161
size_t used
Number of bytes used in the arena buffer.
Definition arena_io.h:57
uint32_t version
Snapshot file format version.
Definition arena_io.h:56
char magic[9]
Magic string ("ARENASNAP\0")
Definition arena_io.h:55
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.
Definition arena_io.c:255
Header structure prepended to saved arena snapshots.
Definition arena_io.h:54
The main memory arena structure used for fast allocation.