Comment by astrange
> such as to serve alignment requests greater than the alignment provided directly by the backing system allocator
Surely the system allocator provides memalign() or similar? Does Windows not have one of those?
> such as to serve alignment requests greater than the alignment provided directly by the backing system allocator
Surely the system allocator provides memalign() or similar? Does Windows not have one of those?
Kind of but not really, the Windows heap doesn't support arbitrary alignments natively, so the aligned malloc function it provides is implemented as a wrapper around the native heap which over-allocates and aligns within the allocated block. The pointer you get back isn't the start of the allocation in the native heap, so you can't pass it to the standard free() without everything exploding.
I don't think fixing that mess was ever a priority for Microsoft because it's mainly an issue for C, and their focus has long been on C++ instead. C++ new/delete knows the alignment of the type being allocated for so it can dispatch to the appropriate path automatically with no overhead in the common <=16 byte case.