pbr-cpp-memory-pool 1.2.0
Fixed-block-size O(1) memory pool — C++17 with an ANSI C public surface
Loading...
Searching...
No Matches
pool_hardening.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// Copyright (c) 2026 Daniel Polo
3
4#ifndef IT_D4NP_MEMORYPOOL_POOL_HARDENING_HPP_
5#define IT_D4NP_MEMORYPOOL_POOL_HARDENING_HPP_
6
42
43#if PBR_MEMORY_POOL_HARDENING
44
45namespace it::d4np::memorypool {
46
59using HardeningViolationHandler = void (*)(const char* kind, const void* block) noexcept;
60
62inline constexpr const char* HARDENING_USE_AFTER_FREE = "use-after-free";
64inline constexpr const char* HARDENING_OVERFLOW = "buffer-overflow";
66inline constexpr const char* HARDENING_DOUBLE_FREE = "double-free";
68inline constexpr const char* HARDENING_FREELIST_CORRUPTION = "free-list-corruption";
69
76
79
80} // namespace it::d4np::memorypool
81
82#endif // PBR_MEMORY_POOL_HARDENING
83
84#endif // IT_D4NP_MEMORYPOOL_POOL_HARDENING_HPP_
Public C API for the pbr-cpp-memory-pool fixed-block-size allocator.
constexpr const char * HARDENING_FREELIST_CORRUPTION
A free-list slot's guard or next-link was corrupted (integrity check).
constexpr const char * HARDENING_DOUBLE_FREE
The same block was freed twice (its guard still read as freed).
HardeningViolationHandler hardening_violation_handler() noexcept
void(*)(const char *kind, const void *block) noexcept HardeningViolationHandler
Handler invoked when the hardening layer detects a violation.
constexpr const char * HARDENING_OVERFLOW
A contiguous write past block_size corrupted the trailing guard word.
constexpr const char * HARDENING_USE_AFTER_FREE
A write to a freed block's poisoned payload was detected on allocation.
HardeningViolationHandler set_hardening_violation_handler(HardeningViolationHandler handler) noexcept
Install handler as the hardening violation handler and return the previous one.