Uses posix_memalign on Posix and __aligned_malloc on Windows.
On Posix, uses alignedAllocate and copies data around because there is no realloc for aligned memory. On Windows, calls __aligned_realloc(b.ptr, newSize, a).
Forwards to alignedAllocate(bytes, platformAlignment).
Calls free(b.ptr) on Posix and __aligned_free(b.ptr) on Windows.
On Posix, forwards to realloc. On Windows, forwards to alignedReallocate(b, newSize, platformAlignment).
The default alignment is platformAlignment.
Returns the global instance of this allocator type. The C heap allocator is thread-safe, therefore all of its methods are static and instance itself is shared.
auto buffer = AlignedMallocator.instance.alignedAllocate(1024 * 1024 * 4, 128); scope(exit) AlignedMallocator.instance.deallocate(buffer); //...