aligned_alloc()

Updated: October 26, 2022

Allocate aligned memory

Synopsis:

#include <malloc.h>

void *aligned_alloc( size_t alignment,
                     size_t size );

Arguments:

alignment
The alignment to use for the block of memory. This must be a multiple of size( void *).
size
The size of the block to allocate, in bytes. This must be a multiple of alignment.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The aligned_alloc() function allocates a block of memory of the given size, and aligned on a boundary specified by the given aligment. It's similar to memalign().

Returns:

A pointer to the allocated memory, or NULL if an error occurred.

Classification:

C11

Safety:  
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes