String memory pool (Arena Allocator) with block recycling.
More...
#include <XLStringArena.hpp>
String memory pool (Arena Allocator) with block recycling.
Adheres to C++ Core Guidelines:
- RAII resource management (no naked new/delete)
- No copy construction/assignment to prevent dangling pointers (Rule of 5)
- Provides zero-copy access via std::string_view
- clear() recycles memory blocks instead of freeing them, eliminating malloc/free churn when the arena is reused across save cycles.
◆ XLStringArena() [1/3]
| OpenXLSX::XLStringArena::XLStringArena |
( |
size_t |
blockSize = 4 * 1024 * 1024 | ) |
|
|
inlineexplicit |
◆ XLStringArena() [2/3]
◆ XLStringArena() [3/3]
◆ capacity()
| size_t OpenXLSX::XLStringArena::capacity |
( |
| ) |
const |
|
inlinenoexcept |
Total bytes allocated (active blocks only).
◆ clear()
| void OpenXLSX::XLStringArena::clear |
( |
| ) |
|
|
inlinenoexcept |
Recycle all blocks for reuse without freeing heap memory.
Moves active blocks to the free list so the next store() calls can reuse them without malloc. Call reset() at shutdown to actually release all memory.
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ reset()
| void OpenXLSX::XLStringArena::reset |
( |
| ) |
|
|
inlinenoexcept |
Release all memory (active + free blocks). Use at shutdown.
◆ store()
| std::string_view OpenXLSX::XLStringArena::store |
( |
std::string_view |
str | ) |
|
|
inline |
Store a string in the arena and return a non-owning view.
- Parameters
-
| str | The string view to store (null-terminated in the arena). |
- Returns
- std::string_view pointing into the arena's storage.
◆ used()
| size_t OpenXLSX::XLStringArena::used |
( |
| ) |
const |
|
inlinenoexcept |
Bytes used in the current active block.
The documentation for this class was generated from the following file: