<div dir="ltr">±ç¤Ñ¨°,<div><br></div><div style>I am guessing you are working on Windows and are running into problems with a mix of runtime heaps. I would suggest avoiding using new and delete directly and instead leaving everything to functions from the GDAL DLL. </div>
<div style><br></div><div style>I believe you should use OGRGeometryFactory::createGeometry(wkbLinearRing) to create the linear ring (use wkbPolygon for the polygon) and OGRGeometryFactory::destroyGeometry() to destroy geometries.  </div>
<div style><br></div><div style>Keep in mind that addRingDirectly() transfers ownership of the ring to the polygon so you should not destroy the ring after that.  It will be cleaned up by the polygon when that is destroyed.</div>
<div style><br></div><div style>Best regards,</div><div style>Frank</div><div style><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, May 13, 2013 at 6:47 PM, ±ç¤Ñ¨° <span dir="ltr"><<a href="mailto:2284168009@qq.com" target="_blank">2284168009@qq.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p>Hello all </p><p>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.</p>
<p> </p><div>int GetWSInfo(const vector<Point> &ring,OUT CWSInfo & wsinfo)<br>{</div><div> OGRLinearRing *poFLinear = new OGRLinearRing();</div><div> poFLinear->setPoints(ring.size(),(OGRRawPoint*)(&ring[0]));<br>
 poFLinear->closeRings();</div><div> OGRPolygon * poFPoly = new OGRPolygon();<br> poFPoly->addRingDirectly(poFLinear);</div><div> wsinfo.WSAREA = poFLinear->get_Area();<br> wsinfo.WSPERI = poFLinear->get_Length();</div>
<div> //delete poFLinear;</div><div> //delete poFPoly;</div><div> return RETURN_OK;<br>}</div><br>_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br>---------------------------------------+--------------------------------------<br>
I set the clouds in motion - turn up   | Frank Warmerdam, <a href="mailto:warmerdam@pobox.com" target="_blank">warmerdam@pobox.com</a><br>light and sound - activate the windows | <a href="http://pobox.com/~warmerdam" target="_blank">http://pobox.com/~warmerdam</a><br>
and watch the world go round - Rush    | Geospatial Software Developer<br>
</div>