stdx.allocator.mallocator
-
Declaration
struct
Mallocator
;The C heap allocator.
Examples
auto buffer = Mallocator.instance.allocate(1024 * 1024 * 4); scope(exit) Mallocator.instance.deallocate(buffer); //...
-
Declaration
enum uint
alignment
;The
alignment
is a static constant equal to , which ensures properalignment
for 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'
s
only useful to safe programs that can afford to leak memory allocated. -
Declaration
static shared Mallocator
instance
;Returns the global
instance
of this allocator type. The C heap allocator is thread-safe, therefore all of its methods andit
itself are .
-
Declaration
struct
AlignedMallocator
;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 uint
alignment
;The default
alignment
is . -
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 bool
deallocate
(void[]b
);Calls on Posix and on Windows.
-
Declaration
shared nothrow @nogc @system bool
reallocate
(ref void[]b
, size_tnewSize
);On Posix, forwards to . On Windows, forwards to .
-
Declaration
static shared AlignedMallocator
instance
;Returns the global
instance
of this allocator type. The C heap allocator is thread-safe, therefore all of its methods and
itself are .instance