INtime SDK Help
_CrtIsMemoryBlock
INtime SDK v7.1 > About INtime > Other system libraries > Heaps and memory pools > Using the Debug Heap > Using Macros for verification and reporting > _CrtIsMemoryBlock

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
);

Parameters

_Memory
Pointer to the beginning of the memory block to verify.
_Bytes
Size of the specified block (bytes).
_RequestNumber
Pointer to the allocation number of the block or NULL.
_Filename
Pointer to name of source file that requested the block or NULL.
_LineNumber
Pointer to the line number in the source file or NULL.

Remarks

_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.

Return Values

TRUE
Success; the specified memory block is located within the local heap and has a valid debug heap block type identifier.
FALSE
Failure. The function sets errno to one of these values:
EINVAL _Memory is invalid.

Requirements

Versions Defined in Include Link to
INtime 3.13 intime/rt/include/crtdbg.h crtdbg.h clib.lib
   
See Also