Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1557309
  • 博文数量: 237
  • 博客积分: 5139
  • 博客等级: 大校
  • 技术积分: 2751
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-18 14:48
文章分类

全部博文(237)

文章存档

2016年(1)

2012年(4)

2011年(120)

2010年(36)

2009年(64)

2008年(12)

分类: C/C++

2009-09-04 17:42:35

今天写程序,遇到问题:分析了下RPointArray的用法。
RPointerArray< TAny > in Base E32

Reset()

inline void Reset();

Description

Empties the array.

It frees all memory allocated to the array and resets the internal state so that it is ready to be reused.

This array object can be allowed to go out of scope after a call to this function. (当退出变量范围的时候,调用这个函数,比如在析构函数中,它只释放数组本身申请的空间并标志成可用,但不释放数组每个成员指针指向的空间,所以调用这个函数会造成内存泄露。 Note: 数组本身相当于指针没置为NULL那种概念

Note that the function does not delete the objects whose pointers are contained in the array. 

RPointerArray in Base E32

ResetAndDestroy()

void ResetAndDestroy();

Description

Empties the array and deletes the referenced objects.

It frees all memory allocated to the array and resets the internal state so that it is ready to be reused. The function also deletes all of the objects whose pointers are contained by the array.

不但释放数组本身的空间,还将释放数组成员指针指向的堆空间,这样不会造成内存泄露

This array object can be allowed to go out of scope after a call to this function. 

RPointerArray in Base E32

Close()

inline void Close();

Description

Closes the array and frees all memory allocated to it.

The function must be called before this array object goes out of scope.

Note that the function does not delete the objects whose pointers are contained in the array. (将数组内容清掉,并close掉。类似于置为NULL了)。






阅读(720) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~