BOOL FAR PASCAL AfxIsValidAddress( const void FAR* lp, UINT nBytes, BOOL bReadWrite = TRUE );
lp
Points to the block of memory to be tested.
nBytes
Contains the length of the memory block in bytes.
bReadWrite
Specifies whether the memory is both for reading and writing.
Tests any memory block to ensure that it is contained entirely within the program's memory space. The address is not restricted to blocks allocated by new.
Note:
With MS-DOS real mode, only addresses with null selectors are invalid; all others are valid. A huge pointer cast to a FAR pointer cannot be used as a parameter to AfxIsValidAddress.
TRUE if the specified memory block is contained entirely within the program's memory space; otherwise FALSE.
char* pbuf = (char*) malloc( 10 );
if( AfxIsValidAddress( pbuf, 10, TRUE ) != TRUE )
exit( 1 ); // Invalid memory