Change handmade_aligned_malloc/realloc/free to store a 1 byte offset instead of absolute address
Reference issue
Fixes #2554 (closed)
What does this implement/fix?
The handmade_aligned_malloc family of functions assumes that malloc will return an address that is aligned to at least sizeof(void*), i.e. alignof(max_align_t) % sizeof(void*) == 0. If this is not true, there may be insufficient space to store original in the offset between aligned and original.
One solution is to store a 1-byte offset aligned-original at aligned-1 and deduce original when needed for realloc and free. This should work for alignment<256 and any alignof(max_align_t).
Additional information
Edited by Charles Schlosser