Allocates memory on a specified alignment boundary with extra space for a debugging header and overwrite buffers (debug version only).
void * _aligned_malloc_dbg( size_t size, size_t alignment, const char *filename, int linenumber );
Size of the requested memory allocation.
The alignment value, which must be an integer power of 2.
Pointer to the name of the source file that requested the allocation operation or
Line number in the source file where the allocation operation was requested or
A pointer to the memory block that was allocated or
NULL if the operation failed.
_aligned_malloc_dbg is a debug version of the
_aligned_malloc function. When
_DEBUG isn't defined, each call to
_aligned_malloc_dbg is reduced to a call to
_aligned_malloc_dbg allocate a block of memory in the base heap, but
_aligned_malloc_dbg offers several debugging features: buffers on either side of the user portion of the block to test for leaks, and
linenumber information to determine the origin of allocation requests. Tracking specific allocation types with a block type parameter isn't a supported debug feature for aligned allocations. Aligned allocations will appear as a
_NORMAL_BLOCK block type.
_aligned_malloc_dbg allocates the memory block with slightly more space than the requested
size. The extra space is used by the debug heap manager to link the debug memory blocks and to provide the application with debug header information and overwrite buffers. When the block is allocated, the user portion of the block is filled with the value 0xCD, and each of the overwrite buffers are filled with 0xFD.
ENOMEM if a memory allocation fails or if the amount of memory needed (including the overhead mentioned previously) exceeds
_HEAP_MAXREQ. For information about this and other error codes, see
_aligned_malloc_dbg validates its parameters. If
alignment isn't a power of 2 or
size is zero, this function invokes the invalid parameter handler, as described in Parameter validation. If execution is allowed to continue, this function returns
NULL and sets
For information about how memory blocks are allocated, initialized, and managed in the debug version of the base heap, see CRT debug heap details. For information about the allocation block types and how they're used, see Types of blocks on the debug heap. For information about the differences between standard heap functions and their debug versions, see Debug versions of heap allocation functions.
For more compatibility information, see Compatibility.
Debug versions of C run-time libraries only.