stdx.allocator.mallocator
-
Declaration
structMallocator;The C heap allocator.
Examples
auto buffer = Mallocator.instance.allocate(1024 * 1024 * 4); scope(exit) Mallocator.instance.deallocate(buffer); //...
-
Declaration
enum uintalignment;The
alignmentis a static constant equal to , which ensures properalignmentfor any D data type. -
Declaration
shared nothrow @nogc @trusted void[]allocate(size_tbytes);
shared nothrow @nogc @system booldeallocate(void[]b);
shared nothrow @nogc @system boolreallocate(ref void[]b, size_ts);Standard allocator methods per the semantics defined above. The and methods are because they may move memory around, leaving dangling pointers in user code. Somewhat paradoxically, is but that'
sonly useful to safe programs that can afford to leak memory allocated. -
Declaration
static shared Mallocatorinstance;Returns the global
instanceof this allocator type. The C heap allocator is thread-safe, therefore all of its methods andititself are .
-
Declaration
structAlignedMallocator;Aligned allocator using OS-specific primitives, under a uniform API.
Examples
auto buffer = AlignedMallocator.instance.alignedAllocate(1024 * 1024 * 4, 128); scope(exit) AlignedMallocator.instance.deallocate(buffer); //...
-
Declaration
enum uintalignment;The default
alignmentis . -
Declaration
shared nothrow @nogc @trusted void[]allocate(size_tbytes);Forwards to .
-
Declaration
shared nothrow @nogc @trusted void[]alignedAllocate(size_tbytes, uinta);Uses on Posix and on Windows.
-
Declaration
shared nothrow @nogc @system booldeallocate(void[]b);Calls on Posix and on Windows.
-
Declaration
shared nothrow @nogc @system boolreallocate(ref void[]b, size_tnewSize);On Posix, forwards to . On Windows, forwards to .
-
Declaration
static shared AlignedMallocatorinstance;Returns the global
instanceof this allocator type. The C heap allocator is thread-safe, therefore all of its methods anditself are .instance