Skip to content

POSIX allocate aligned memory

stackoverflow aligned malloc() in GCC? # A

See the memalign family of functions.

posix_memalign(3)

       #include <stdlib.h>

       int posix_memalign(void **memptr, size_t alignment, size_t size);
       void *aligned_alloc(size_t alignment, size_t size);
       void *valloc(size_t size);

       #include <malloc.h>

       void *memalign(size_t alignment, size_t size);
       void *pvalloc(size_t size);