void *memalign(size_t blocksize,
The memalign() function returns a block of memory of
size bytes aligned to blocksize.
The blocksize must be given as a power of two. It sets
errno and returns a null pointer upon failure.
Pointers returned by memalign() may be passed to
free(). Pointers passed to realloc()
are checked and if not aligned to the system, the realloc()
fails and returns NULL.
Is the size of the aligned block.
Is the number of bytes to be allocated.
If successful, the memalign() function returns the pointer
to the start of the aligned memory.
If an error occurs, it returns a null pointer and sets errno
to one of the following:
The blocksize parameter
is not a power of two.
memalign() is a wrapper around malloc().
The memalign() function allocates from a private heap.
Do not mix with Win32 heap allocation functions.
Memory allocated with memalign() should only be freed with
Unlike many UNIX platforms, the heap that is used by
calloc(), and realloc() is not guaranteed
to be one contiguous piece of memory.
Thus it is invalid to assume that all memory
between two pointers returned by these functions are
accessible, and it is invalid to compare pointers returned by
these functions to determine the total size of the heap.
It is recommended that new code
not use this function and it is further recommended that its use
in older code be reconsidered. It is only included to allow older
code to recompile. The UNIX 98 specification does not have this
function. Most modern operating systems memory allocation
routines return aligned memory.
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition
- free(), malloc(), realloc(), valloc()
PTC MKS Toolkit 10.1 Documentation Build 15.