[gdal-dev] [ogr_geometry.h ]Detected memory leaks when using c++ operator new
梁天辰
2284168009 at qq.com
Mon May 13 18:47:11 PDT 2013
Hello all
The following function uses c++ operator new to get a pointer of OGRLinearRing and modified that ring. Before the function returns, it's neccessary to delete that pointer,but "delete poFLinear;" will cause a runtime error and the program stops running. What should I do to delete that pointer? Thanks.
int GetWSInfo(const vector<Point> &ring,OUT CWSInfo & wsinfo)
{
OGRLinearRing *poFLinear = new OGRLinearRing();
poFLinear->setPoints(ring.size(),(OGRRawPoint*)(&ring[0]));
poFLinear->closeRings();
OGRPolygon * poFPoly = new OGRPolygon();
poFPoly->addRingDirectly(poFLinear);
wsinfo.WSAREA = poFLinear->get_Area();
wsinfo.WSPERI = poFLinear->get_Length();
//delete poFLinear;
//delete poFPoly;
return RETURN_OK;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20130514/f050a677/attachment.html>
More information about the gdal-dev
mailing list