- UID
- 124967
- 积分
- 180
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2004-4-14
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
Freeing Strings Returned as Non-const Pointers
When calling methods that return non-const string pointers (for example, AcDbSymbolTable::getName(char&* pName)), you should free the memory occupied by the returned string. For example:
// The getName() call should be followed by a call to acutDelString(pLtName);
pLtTableRcd->getName(pLtName);
// ... other code
acutDelString(pLtName);
Note that some of the ObjectARX sample files are missing calls to free the memory, so they will exhibit memory leaks. When using the samples in your own code, make sure to free the memory properly.
以下是翻译,如果不好不要见怪:
标题:记得释放一个函数返回的非常量字符串指针所指向的内存
当调用一个返回非常量字符串指针的函数时(例如,AcDbSymbolTable::getName(char&* pName)),调用者要负责释放被返回的字符串占用的内存。例如:
// 调用getName()函数后必须紧跟着调用acutDelString(pLtName)
pLtTableRcd->getName(pLtName);
// ... 其它代码
acutDelString(pLtName);
需要注意的是,有些ObjectARX文档的例子里面也没有调用函数去释放内存,因此它们会造成内存泄漏。当在你自己的代码里使用ObjectARX的例子时,要确认你正确地释放了内存。 |
|