std.experimental.allocator.mallocator
The C heap allocator.
Types 2
structMallocator
The C heap allocator.
Fields
uint alignmentThe alignment is a static constant equal to `platformAlignment`, which ensures proper alignment for any D data type.Mallocator instanceReturns the global instance of this allocator type. The C heap allocator is thread-safe, therefore all of its methods and `it` itself are `shared`.Methods
void[] allocate(size_t bytes) @trusted @nogc nothrow pure shared constStandard allocator methods per the semantics defined above. The `deallocate` and `reallocate` methods are `@system` because they may move memory around, leaving dangling pointers in user code. Some...structAlignedMallocator
Aligned allocator using OS-specific primitives, under a uniform API.
Fields
uint alignmentThe default alignment is `platformAlignment`.AlignedMallocator instanceReturns the global instance of this allocator type. The C heap allocator is thread-safe, therefore all of its methods and `instance` itself are `shared`.Methods
bool reallocate(ref void[] b, size_t newSize) @system @nogc nothrow pure sharedForwards to alignedReallocate(b). Should be used with blocks obtained with `allocate` otherwise the custom alignment passed with `alignedAllocate` can be lost.