#include <poisonable.h>
Public Member Functions | |
constexpr uintptr_t | GetPoisonWord () const |
Returns the value written to a block's usable space when poisoning. | |
constexpr bool | IsPoisoned () const |
Returns whether this block has been poisoned. | |
constexpr void | Poison () |
Static Public Attributes | |
static constexpr size_t | kPoisonOffset = Derived::ReservedWhenFree() |
Protected Member Functions | |
constexpr uintptr_t | DoGetPoisonWord () const |
constexpr Derived * | DoSplitFirst (size_t new_inner_size) |
constexpr Derived * | DoSplitLast (size_t new_inner_size) |
constexpr void | DoMergeNext () |
constexpr bool | DoCheckInvariants (bool strict) const |
Like IsValid , but crashes if invalid. | |
constexpr void | SetFree (bool is_free) |
Clears the poisoned state if a block is not free. | |
Mix-in for blocks that can be poisoned.
A poisoned block's usable space contains pattern of data whose integrity can be checked later for modification.
Block mix-ins are stateless and trivially constructible. See BasicBlock
for details on how mix-ins can be combined to implement blocks.
This mix-in requires its derived type also derive from ContiguousBlock
and provide the following method:
|
constexprprotected |
Like IsValid
, but crashes if invalid.
|
constexprprotected |
Merges this block with next block.
This method is static in order to consume and replace the given block pointer with a pointer to the new, larger block.
|
constexprprotected |
Split a block into two smaller blocks.
This method splits a block into a leading block of the given new_inner_size
and a trailing block, and returns the trailing space as a new block.
|
constexprprotected |
Split a block into two smaller blocks.
This method splits a block into a leading block and a trailing block of the given new_inner_size
, and returns the trailing space is returned as a new block.
|
constexpr |
Poisons the block's usable space.
This method does nothing if the block is not free. The decision to poison a block is delegated to the allocator to allow for more nuanced strategies than simply all or nothing. For example, an allocator may want to balance security and performance by only poisoning every n-th free block.