Verifies that a specified memory block is in the local heap and that it has a valid debug heap block type identifier (debug version only).
int _CrtIsMemoryBlock ( const void * _Memory, unsigned int _Bytes, long * _RequestNumber, char ** _Filename, int * _LineNumber );
_Memory
_Bytes
_RequestNumber
NULL
.
_Filename
NULL
.
_LineNumber
NULL
. _CrtIsMemoryBlock verifies that a specified memory block is located within the application's heap and that it has a valid block type identifier. You can also use this function to obtain the object allocation order number and source file name/line number where the memory block allocation was originally requested. Passing non-NULL values for the _RequestNumber
, _Filename
, or _LineNumber
parameters causes _CrtIsMemoryBlock to set these parameters to the values in the memory block's debug header, if it finds the block in the local heap. When _DEBUG is not defined, preprocessing removes calls to _CrtIsMemoryBlock.
Because this function returns TRUE or FALSE, you can pass it to one of the _ASSERT macros to create a simple debugging error handling mechanism. The following example causes an assertion failure if the specified address is not located within the local heap:
_ASSERTE( _CrtIsMemoryBlock( _Memory, _Bytes, &_RequestNumber, &_Filename, &_LineNumber ) );
For more information about how _CrtIsMemoryBlock can be used with other debug functions and macros, see Using Macros for Verification and Reporting. For information about how memory blocks are allocated, initialized, and managed in the debug version of the base heap, see Memory Management and the Debug Heap.
EINVAL |
_Memory is invalid. |
Versions | Defined in | Include | Link to |
---|---|---|---|
INtime 3.13 | intime/rt/include/crtdbg.h | crtdbg.h | clib.lib |