|Linux / Unix Command: posix_memalign|
NAMEposix_memalign, memalign, valloc - Allocate aligned memory
#include <stdlib.h> int posix_memalign(void **memptr, size_t alignment, size_t size); void *memalign(size_t boundary, size_t size); void *valloc(size_t size);
DESCRIPTIONThe function posix_memalign() allocates size bytes and places the address of the allocated memory in *memptr. The address of the allocated memory will be a multiple of alignment, which must be a power of two and a multiple of sizeof(void *).
The obsolete function memalign() allocates size bytes and returns a pointer to the allocated memory. The memory address will be a multiple of boundary, which must be a power of two.
The obsolete function valloc() allocates size bytes and returns a pointer to the allocated memory. The memory address will be a multiple of the page size. It is equivalent to memalign(sysconf(_SC_PAGESIZE),size).
For all three routines, the memory is not zeroed.
RETURN VALUEmemalign() and valloc() return the pointer to the allocated memory, or NULL if the request fails.
posix_memalign() returns zero on success, or one of the error values listed in the next section on failure. Note that errno is not set.
- The alignment parameter was not a power of two, or was not a multiple of sizeof(void *).
There was insufficient memory to fulfill the allocation request.
SEE ALSOmalloc(3), free(3), getpagesize(2), brk(2)
Important: Use the man command (% man) to see how a command is used on your particular computer.