还在苦苦敲代码开发APP?你out啦! 试试积木搭建APP吧~

AfxIsValidAddress 测试内存地址

来源:转载     2016-08-19 16:16:25    人气:     我有话说( 0 人参与)

Tests any memory address to ensure that it is contained entirely within the program& 39;s memory space 测试任何内存

Tests any memory address to ensure that it is contained entirely within the program's memory space.

测试任何内存地址,以确保它是完全包含在程序的内存空间。

BOOL AfxIsValidAddress(
   const void* lp,
   UINT nBytes,
   BOOL bReadWrite = TRUE 
); 

 

Parameters

lp

Points to the memory address to be tested.

指向被测试内存。

nBytes

Contains the number of bytes of memory to be tested.

包含被测试内存的字节个数。

bReadWrite

Specifies whether the memory is both for reading and writing (TRUE) or just reading (FALSE).

确定被测试内存是读写形式(真)还是只读形式(假)。


Return Value

In debug builds, nonzero if the specified memory block is contained entirely within the program's memory space; otherwise 0.

在调试版,如果指定的内存被完全包含在程序的内存空间,返回值不为0,否则为0.

In non-debug builds, nonzero if lp is not NULL; otherwise 0.

在调试构建,如果lp不为空,返回值不为0,否则返回值为0.
 

Remarks

The address is not restricted to blocks allocated by new.

地址不仅限于模块分配新的地址。
 

Example

// Allocate a 5 character array, which should have a valid memory address.
char* arr = new char[5];

// Create a null pointer, which should be an invalid memory address.
char* null = (char*)0x0;

ASSERT(AfxIsValidAddress(arr, 5));
ASSERT(!AfxIsValidAddress(null, 5));


Requirements

Header: afx.h


AfxIsValidAddress

本文源自互联网,采用知识共享署名-非商业性使用 4.0 国际许可协议进行许可,
版权归原作者,如有问题请联系service@tsingfun.com (编辑:admin)
分享到: