Frank, this was the problem. Thanks for your help.<div><br></div><div>For the list archives, here is another working sample (essentially the same as what Frank put below).</div><div><br></div><div><div>OGRPoint* p = (OGRPoint*)OGRGeometryFactory::createGeometry(wkbPoint);</div>
<div>p->setX(3.141);</div><div>p->setY(2.718);</div><div>OGRGeometryFactory::destroyGeometry(p);</div><div><br></div><div><br></div><div><br></div><br><div class="gmail_quote">On Wed, Oct 22, 2008 at 10:23 AM, Frank Warmerdam <span dir="ltr"><<a href="mailto:warmerdam@pobox.com">warmerdam@pobox.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="Ih2E3d">Joel Odom wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Anybody knows why these two lines of code cause corruption on the heap? Thanks.<br>
<br>
OGRPoint* ogr_point = new OGRPoint(5.0, 5.0);<br>
delete ogr_point;<br>
</blockquote>
<br></div>
Joel,<br>
<br>
My guess is that you are doing this "cross heap". Are you running on windows?<br>
Do you build your application calling OGR with /MD? If not your application<br>
code may have a distinct heap from the GDAL DLL and this makes it very hard<br>
to safely create and destroy c++ objects using new and delete.<br>
<br>
Assuming you don't want to harmonize the heap, the normal solution is to<br>
ensure creation and destruction are done within the DLL. So change to<br>
something like:<br>
<br>
OGRPoint *ogr_point = (OGRPoint *)<br>
OGRGeometryFactory::createGeometry( wkbPoint );<br>
<br>
ogr_point->setX( 5.0 );<br>
ogr_point->setY( 5.0 );<br>
<br>
...<br>
<br>
OGRGeometryFactory::destroyGeometry( ogr_point );<br>
<br>
Best regards,<br><font color="#888888">
-- <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 Programmer for Rent<br>
<br>
</font></blockquote></div><br><br clear="all"><br>-- <br><a href="http://giscoder.blogspot.com/">http://giscoder.blogspot.com/</a><br>
</div>