aligned_alloc - aligned memory allocation
void *aligned_alloc(size_t alignment, size_t size);
The aligned_alloc() function allocates size bytes on a specified alignment boundary and returns a pointer to the allocated block.
The alignment argument must be a valid alignment, that is, any power of two (1, 2, 4, 8, ...) and the size argument must be an integral multiple of alignment.
The free(3C) function will deallocate memory that has previously been allocated by aligned_alloc().
Upon successful completion, aligned_alloc() returns a pointer to the allocated space. Otherwise, aligned_alloc() returns a null pointer and sets errno to indicate the error.
The aligned_alloc() function will fail if:
The value of alignment is not a power of two, or size is not a non-zero integral multiple of alignment.
There is insufficient memory available with the requested alignment.
See attributes(7) for descriptions of the following attributes:
The aligned_alloc() function is specified in the C11 standard (INCITS/ISO/IEC 9899:2011).