Defined in header
size bytes of uninitialized storage whose alignment is specified by
size parameter must be an integral multiple of
The following functions are required to be thread-safe:
Calls to these functions that allocate or deallocate a particular unit of storage occur in a single total order, and each such deallocation call happens-before the next allocation (if any) in this order.
|alignment||-||specifies the alignment. Must be a valid alignment supported by the implementation.|
|size||-|| number of bytes to allocate. An integral multiple of |
On success, returns the pointer to the beginning of newly allocated memory. The returned pointer must be deallocated with free() or
On failure, returns a null pointer.
size which is not an integral multiple of
alignment or a
alignment which is not valid or not supported by the implementation causes the function to fail and return a null pointer (C11, as published, specified undefined behavior in this case, this was corrected by DR 460).
As an example of the "supported by the implementation" requirement, POSIX function posix_memalign accepts any
alignment that is a power of two and a multiple of
sizeof(void*), and POSIX-based implementations of
aligned_alloc inherit this requirements.
Regular std::malloc aligns memory suitable for any object type (which, in practice, means that it is aligned to alignof(std::max_align_t)). This function is useful for over-aligned allocations, such as to SSE, cache line, or VM page boundary.
default-aligned addr: 0x2221c20 1024-byte aligned addr: 0x2222000
| defines the type suitable for use as uninitialized storage for types of given size |