![]() |
Signet Forge 0.1.0
C++20 Parquet library with AI-native extensions
|
DEMO |
Bump-pointer arena allocator for batch Parquet reads. More...
#include <memory.hpp>
Public Member Functions | |
| Arena (size_t block_size=64 *1024) | |
| Construct an arena with the given default block size. | |
| ~Arena ()=default | |
| void * | allocate (size_t size, size_t alignment=8) |
| Allocate aligned memory from the arena. | |
| void * | allocate_zeroed (size_t size, size_t alignment=alignof(std::max_align_t)) |
| Allocate zero-initialized memory from the arena. | |
| template<typename T > | |
| T * | allocate_array (size_t count) |
Allocate a typed array of count elements from the arena. | |
| const uint8_t * | copy (const uint8_t *data, size_t size) |
| Copy raw bytes into the arena and return a pointer to the copy. | |
| const char * | copy_string (const std::string &str) |
| Copy a string into the arena (including null terminator). | |
| size_t | bytes_used () const |
| Total bytes allocated (excluding alignment padding). | |
| void | reset () |
| Reset the arena, reusing all memory blocks without freeing them. | |
| Arena (const Arena &)=delete | |
| Non-copyable. | |
| Arena & | operator= (const Arena &)=delete |
| Non-copyable. | |
| Arena (Arena &&) noexcept=default | |
| Move-constructible. | |
| Arena & | operator= (Arena &&) noexcept=default |
| Move-assignable. | |
Bump-pointer arena allocator for batch Parquet reads.
Maintains a list of memory blocks. Allocations bump a pointer within the current block; when a block is exhausted a new one is allocated. reset() recycles all blocks without freeing, making them available for reuse.
Non-copyable, movable. Thread-safety: not thread-safe – callers must synchronize externally if shared across threads.
Definition at line 33 of file memory.hpp.
|
inlineexplicit |
Construct an arena with the given default block size.
| block_size | Default allocation block size in bytes (default 64 KiB). |
Definition at line 37 of file memory.hpp.
|
default |
|
delete |
Non-copyable.
|
defaultnoexcept |
Move-constructible.
|
inline |
Allocate aligned memory from the arena.
Attempts to satisfy the allocation from the current block. If the current block cannot accommodate the request, a new block is allocated whose size is at least size + alignment or block_size_, whichever is larger.
| size | Number of bytes to allocate (0 returns nullptr). |
| alignment | Required alignment (must be a power of 2, default 8). |
size is 0. Definition at line 52 of file memory.hpp.
|
inline |
Allocate a typed array of count elements from the arena.
Elements are not constructed (raw memory only). The alignment is derived from alignof(T).
| T | Element type. |
| count | Number of elements (0 returns nullptr). |
count is 0. Definition at line 107 of file memory.hpp.
|
inline |
Allocate zero-initialized memory from the arena.
CWE-908: Use of Uninitialized Resource — zeroing prevents information leaks from recycled arena blocks or stale heap memory.
Equivalent to allocate() followed by memset to zero. Useful for security-sensitive buffers where uninitialized memory could leak data.
| size | Number of bytes to allocate (0 returns nullptr). |
| alignment | Required alignment (must be a power of 2, default max_align_t). |
size is 0. Definition at line 92 of file memory.hpp.
|
inline |
Total bytes allocated (excluding alignment padding).
Definition at line 141 of file memory.hpp.
|
inline |
Copy raw bytes into the arena and return a pointer to the copy.
| data | Source bytes to copy (nullptr returns nullptr). |
| size | Number of bytes to copy (0 returns nullptr). |
Definition at line 119 of file memory.hpp.
|
inline |
Copy a string into the arena (including null terminator).
| str | The string to copy. |
Definition at line 131 of file memory.hpp.
|
inline |
Reset the arena, reusing all memory blocks without freeing them.
After reset, subsequent allocations reuse existing block memory. This avoids the cost of repeated malloc/free across batches.
Definition at line 147 of file memory.hpp.