ALIGNED_ALLOC(3C) Standard C Library Functions ALIGNED_ALLOC(3C)

aligned_allocaligned memory allocation

#include <stdlib.h>

void *
aligned_alloc(size_t alignment, size_t size);

The () function allocates size bytes aligned on the specified alignment boundary alignment. The value of alignment is constrained: it must be a power of two.

Upon successful completion, the aligned_alloc() function returns a pointer to suitably aligned memory at least size bytes large. Otherwise, a pointer is returned and is set to indicate the error.

The aligned_alloc() function will fail if:

The physical limits of the system are exceeded by size bytes of memory which cannot be allocated.
There is not enough memory available to allocate size bytes of memory; but the application could try again later.
An invalid value for alignment was passed in. It is not a power of two.

malloc(3C), memalign(3C), posix_memalign(3C), attributes(7)

May 11, 2024 OmniOS