Manual memory management routines.
Returns true if A is an unaligned allocator.
The following code should compile for any unaligned allocator.
A a = void; auto p = a.tryUnalignedAllocate(cast(size_t) 1); auto q = a.tryUnalignedReallocate(p, cast(size_t) 1, cast(size_t) 1); a.unalignedFree(p); static assert(is(typeof(p) == void*) && is(typeof(q) == void*));
Requests a properly aligned block of memory of count * T.sizeof bytes from allocator.
If initialize is true the returned memory will be set to T.init.
If allocation fails allocate will also call core.exception.onOutOfMemoryError
which is expected to throw an core.exception.OutOfMemoryError.
Requests resize of a properly aligned block of memory allocated from allocator or if ptr is null requests memory allocation like allocate/tryAllocate. Memory may be moved, but array elements content will stay the same.
If initialize is true and array.length < newCount the memory of
"rest" elements will be set to T.init.
If reallocation fails array isn't changed.
tryReallocate returns whether reallocation succeeded.
If reallocation fails reallocate will also call core.exception.onOutOfMemoryError
which is expected to throw an core.exception.OutOfMemoryError.
Deallocates the memory referenced by array.ptr from allocator and sets array to null.
If array.ptr is null, no action occurs.
Deallocates the memory referenced by ptr from allocator.
If ptr is null, no action occurs.
Requests an alignment-byte aligned block of memory of count * elementSize bytes from allocator.
If zeroFill is true the returned memory will be zero-filled.
If allocation fails rawAllocate will also call core.exception.onOutOfMemoryError
which is expected to throw an core.exception.OutOfMemoryError.
Requests resize of an alignment-byte aligned block of memory allocated from allocator or if ptr is null requests memory allocation like rawAllocate/tryRawAllocate. Memory may be moved, but preserveCount elements content will stay the same.
If zeroFill is true and preserveCount < newCount the memory of
"unpreserved" elements will be zero-filled.
If reallocation fails ptr isn't changed.
tryRawReallocate returns whether reallocation succeeded.
If reallocation fails rawReallocate will also call core.exception.onOutOfMemoryError
which is expected to throw an core.exception.OutOfMemoryError.
Deallocates the memory referenced by ptr from allocator.
If ptr is null, no action occurs.
An unaligned shared allocator which can be safely used from multiple threads.
An unaligned thread local allocator.
It can be faster than heap as it doesn't require a synchronization.
An unaligned allocator which uses C's malloc/free.
Creates temporary buffer.
Returned object has two properties: ptr to access the buffer as T*
and arr to access it as T[].
The temporary buffer is valid unless returned object is destroyed.
Thus if returned object is assigned to a variable the temporary is
valid unless the variable goes out of scope. If returned object isn't
assigned to a variable it will be destroyed at the end of creating
primary expression.
If count <= stackCount or stackCount isn't specified and
no more than 1 KiB is requested tempAlloc will use stack allocated
buffer, for larger requests it will allocate temporary buffer
from threadHeap.