|
| MDBXC_NODISCARD MDBX_val | view_copy (const void *p, size_t n) |
| | Copy n bytes from p into bytes and return a view.
|
| |
| MDBXC_NODISCARD MDBX_val | view_bytes () const noexcept |
| | Return a view over current bytes (no copy).
|
| |
| MDBXC_NODISCARD MDBX_val | view_small_copy (const void *p, size_t n) noexcept |
| | Copy n bytes into the small inline buffer and return a view.
|
| |
| void | assign_bytes (const void *p, size_t n) |
| | Replace bytes content with a copy of p..p+n .
|
| |
| void | clear () noexcept |
| | Optionally clear and release capacity.
|
| |
Per-call scratch buffer to produce MDBX_val without using thread_local.
Why not thread_local? On Windows/MinGW, destructors of thread_local STL containers (e.g. std::vector) may run at thread teardown when parts of CRT/heap are already being finalized or when different heap arenas are involved. This can lead to heap corruption or std::terminate() without an exception.
To avoid those issues, we keep a small stack-like inline buffer and a per-call dynamic buffer owned by the caller object (not thread_local). The lifetime of returned MDBX_val is guaranteed only until the next call that mutates this scratch, or until it goes out of scope.
Invariants & usage:
view(...) does not copy; caller must ensure (ptr,len) lives through the MDBX call.
view_small_copy(...) copies up to 16 bytes into an aligned inline buffer. It is intended for small keys (e.g., 4/8-byte INTEGERKEY).
view_copy(...) and assign_bytes(...) own copied data in bytes.
view_bytes() exposes the current contents of bytes without copying.
- Do not store the returned
MDBX_val beyond the scope of immediate MDBX API call.
Definition at line 168 of file utils.hpp.