There exist several aligned versions of the venerable malloc()
, e.g.:
#include <stdlib.h>
int posix_memalign(void **memptr, size_t alignment, size_t size);
void *aligned_alloc(size_t alignment, size_t size);
#include <malloc.h>
void *memalign(size_t alignment, size_t size);
(originating in POSIX, glibc and Linux libc respectively). But - I can't seem to find any mention of a version of realloc()
which supports alignment. Has it really never been implemented? It seems pretty trivial to combine the functionality of non-aligned realloc()
with the search for an aligned chunk of memory in the aligned malloc()
variants.
Related:
Does realloc keep the memory alignment of posix_memalign?