Export (0) Print
Expand All
div
eof
Expand Minimize
1 out of 2 rated this helpful - Rate this topic

_CrtIsValidPointer 

Verifies that a specified memory range is valid for reading and writing (debug version only).


int _CrtIsValidPointer( 
   const void *address,
   unsigned int size,
   int access 
);

Parameters

address

Points to the beginning of the memory range to test for validity.

size

Size of the specified memory range (in bytes).

access

Read/write accessibility to determine for the memory range.

_CrtIsValidPointer returns TRUE if the specified memory range is valid for the specified operation or operations. Otherwise, the function returns FALSE.

The _CrtIsValidPointer function verifies that the memory range beginning at address and extending for size bytes is valid for the specified accessibility operation or operations. When access is set to TRUE, the memory range is verified for both reading and writing. When address is FALSE, the memory range is only validated for reading. When _DEBUG is not defined, calls to _CrtIsValidPointer are removed during preprocessing.

Because this function returns TRUE or FALSE, it can be passed to one of the _ASSERT macros to create a simple debugging error handling mechanism. The following example causes an assertion failure if the memory range is not valid for both reading and writing operations:

_ASSERTE( _CrtIsValidPointer( address, size, TRUE ) );

For more information about how _CrtIsValidPointer 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.

Routine Required header Compatibility

_CrtIsValidPointer

<crtdbg.h>

Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition, Windows Millennium Edition, Windows NT 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003

For more compatibility information, see Compatibility in the Introduction.

Libraries

Debug versions of C run-time libraries only.

See the example for the _CrtIsValidHeapPointer topic.

Not applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.