c/memory/aligned alloc

Allocate bytes of uninitialized storage whose alignment is specified by. The parameter must be an integral multiple of.

is thread-safe: it behaves as though only accessing the memory locations visible through its argument, and not any static storage.

A previous call to free or realloc that deallocates a region of memory synchronizes-with a call to aligned_alloc that allocates the same or a part of the same region of memory. This synchronization occurs after any access to the memory by the deallocating function and before any access to the memory by. There is a single total order of all allocation and deallocation functions operating on each particular region of memory.

Return value
On success, returns the pointer to the beginning of newly allocated memory. To avoid a memory leak, the returned pointer must be deallocated with free or realloc.

On failure, returns a null pointer.