std.experimental.allocator.building_blocks.scoped_allocator

Types 1

structScopedAllocator(ParentAllocator)

ScopedAllocator delegates all allocation requests to ParentAllocator. When destroyed, the ScopedAllocator object automatically calls deallocate for all memory allocated through its lifetime. (The deallocateAll function is also implemented with the same semantics.)

deallocate is also supported, which is where most implementation effort and overhead of ScopedAllocator go. If deallocate is not needed, a simpler design combining AllocatorList with Region is recommended.

Fields
private Node * root
Allocator.alignment alignmentAlignment offered
private q{ if (!b.ptr) return b; Node* toInsert = & parent.prefix(b); toInsert.prev = null; toInsert.next = root; toInsert.length = n; assert(!root || !root.prev); if (root) root.prev = toInsert; root = toInsert; return b; } _processAndReturnAllocateResult
Methods
size_t goodAllocSize(size_t n)Forwards to `parent.goodAllocSize` (which accounts for the management overhead).
void[] allocate(size_t n)Allocates memory. For management it actually allocates extra memory from the parent.
bool reallocate(ref void[] b, size_t s)Reallocates `b` to new size `s`.
bool deallocateAll()Deallocates all memory allocated.
Ternary empty() pure nothrow @safe @nogc constReturns `Ternary.yes` if this allocator is not responsible for any memory, `Ternary.no` otherwise. (Never returns `Ternary.unknown`.)
Destructors
~this`ScopedAllocator`'s destructor releases all memory allocated during its lifetime.
Nested Templates
Node