|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer|
Allocates memory on a specified alignment boundary.
- [in] size
The size of the requested memory allocation.
- [in] alignment
The alignment value, which must be an integer power of 2.
- [in] offset
The offset into the memory allocation to force the alignment.
_aligned_offset_malloc is useful in situations where alignment is needed on a nested element; for example, if alignment was needed on a nested class.
_aligned_offset_malloc is based on malloc; for more information, see malloc.
_aligned_offset_malloc is marked __declspec(noalias) and __declspec(restrict), meaning that the function is guaranteed not to modify global variables and that the pointer returned is not aliased. For more information, see noalias and restrict.
In Visual C++ 2005, this function sets errno to ENOMEM if the memory allocation failed or if the requested size was greater than _HEAP_MAXREQ. For more information about errno, see alignment is not a power of 2 or if offset is greater than or equal to size and nonzero, this function invokes the invalid parameter handler, as described in . If execution is allowed to continue, this function returns NULL and sets errno to EINVAL.. Also, _aligned_offset_malloc validates its parameters. If