查看单个帖子
旧 2009-05-06, 05:38 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】memory leaks in exhostappservices.cpp

memory leaks in exhostappservices.cpp
memory leaks in exhostappservices.cpp
in exhostappservices.cpp in dwgdirect 2.1.0, there are a number of places where 'delete' is being used instead of 'delete[]' that are likely to cause memory leaks. these include:
line #260:
code:
char* lpdata = new char[ndatasize];
...
delete lpdata;
line #295, 296
code:
tchar* lpvalname = new tchar[nvalnamesize];
lpbyte lpdata = new byte[ndatasize];
...
delete lpvalname;
delete lpdata;
i think for a correct coding perspective this is correct, however since the arrays are simple characters arrays, this would not produce memory leaks as i understand it. (ie char's dont have destructors).
also according do ibm documentation :
the result of deleting an array object with delete is undefined.
so to be safe, i agree, from both a consistency point & and documentation point.
cheers
jason
quote:
originally posted by tenbrink
in exhostappservices.cpp in dwgdirect 2.1.0, there are a number of places where 'delete' is being used instead of 'delete[]' that are likely to cause memory leaks. these include:
line #260:
code:
char* lpdata = new char[ndatasize];
...
delete lpdata;
line #295, 296
code:
tchar* lpvalname = new tchar[nvalnamesize];
lpbyte lpdata = new byte[ndatasize];
...
delete lpvalname;
delete lpdata;
last edited by janderssen; 2nd november 2006 at 08:32 pmfff">.
we'll correct these places, though that is, as jason correctly states, just a consistency matter.
btw - how did you discover them - perhaps there is some tool?
vladimir
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)