mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-28 12:18:25 +00:00
C++17 introduced aligned versions of `new` and `delete`, which are automatically called by the compiler when allocating over-aligned objects. As with the regular allocator functions, these are generally thin wrappers around LibC. We did not have support for aligned allocations in LibC, so this was not possible. While libstdc++ has a fallback implementation, libc++ does not, so the aligned allocation function was disabled internally. This made building the LLVM port with Clang impossible. Note that while the Microsoft docs say that aligned_malloc and _aligned_free are declared in `malloc.h`, libc++ doesn't #include that file, but instead relies on the definition coming from `stdlib.h`. Therefore, I chose to declare it in that file instead of creating a new LibC header. I chose not to implement the more Unix-y `memalign`, `posix_memalign`, or the C11 `aligned_alloc`, because that would require us to significantly alter the memory allocator's internals. See the comment in malloc.cpp.
19 KiB
19 KiB