std.experimental.allocator.building_blocks.null_allocator

Source
std/experimental/allocator/building_blocks/null_allocator.d
struct NullAllocator;

NullAllocator is an emphatically empty implementation of the allocator interface. Although it has no direct use, it is useful as a "terminator" in composite allocators.

enum uint alignment;

NullAllocator advertises a relatively large alignment equal to 64 KB. This is because NullAllocator never actually needs to honor this alignment and because composite allocators using NullAllocator shouldn't be unnecessarily constrained.

shared pure nothrow @nogc @safe void[] allocate(size_t);

Always returns null.

shared pure nothrow @nogc @safe void[] alignedAllocate(size_t, uint);

Always returns null.

shared pure nothrow @nogc @safe void[] allocateAll();

Always returns null.

shared pure nothrow @nogc @safe bool expand(ref void[] b, size_t s);

shared pure nothrow @nogc @safe bool reallocate(ref void[] b, size_t);

shared pure nothrow @nogc @safe bool alignedReallocate(ref void[] b, size_t, uint);

These methods return false.

Precondition
b is null. This is because there is no other possible legitimate input.
shared const pure nothrow @nogc @safe Ternary owns(const void[]);

Returns Ternary.no.

shared const pure nothrow @nogc @safe Ternary resolveInternalPointer(const void*, ref void[]);

Returns Ternary.no.

shared pure nothrow @nogc @safe bool deallocate(void[] b);

No-op.

Precondition
b is null
shared pure nothrow @nogc @safe bool deallocateAll();

No-op.

shared const pure nothrow @nogc @safe Ternary empty();

Returns Ternary.yes.

static shared NullAllocator instance;

Returns the shared global instance of the NullAllocator.

© 1999–2021 The D Language Foundation
Licensed under the Boost License 1.0.
https://dlang.org/phobos/std_experimental_allocator_building_blocks_null_allocator.html