几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   DirectDWG (http://www.dimcax.com/hust/forumdisplay.php?f=89)
-   -   【转帖】memory leaks in exhostappservices.cpp (http://www.dimcax.com/hust/showthread.php?t=17177)

yang686526 2009-05-06 05:38 PM

【转帖】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


所有的时间均为北京时间。 现在的时间是 02:23 PM.