Frank, this was the problem. Thanks for your help. For the list archives, here is another working sample (essentially the same as what Frank put below).
OGRPoint* p = (OGRPoint*)OGRGeometryFactory::createGeometry(wkbPoint); p->setX(3.141); p->setY(2.718); OGRGeometryFactory::destroyGeometry(p); On Wed, Oct 22, 2008 at 10:23 AM, Frank Warmerdam <[EMAIL PROTECTED]>wrote: > Joel Odom wrote: > >> Anybody knows why these two lines of code cause corruption on the heap? >> Thanks. >> >> OGRPoint* ogr_point = new OGRPoint(5.0, 5.0); >> delete ogr_point; >> > > Joel, > > My guess is that you are doing this "cross heap". Are you running on > windows? > Do you build your application calling OGR with /MD? If not your > application > code may have a distinct heap from the GDAL DLL and this makes it very hard > to safely create and destroy c++ objects using new and delete. > > Assuming you don't want to harmonize the heap, the normal solution is to > ensure creation and destruction are done within the DLL. So change to > something like: > > OGRPoint *ogr_point = (OGRPoint *) > OGRGeometryFactory::createGeometry( wkbPoint ); > > ogr_point->setX( 5.0 ); > ogr_point->setY( 5.0 ); > > ... > > OGRGeometryFactory::destroyGeometry( ogr_point ); > > Best regards, > -- > > ---------------------------------------+-------------------------------------- > I set the clouds in motion - turn up | Frank Warmerdam, > [EMAIL PROTECTED] > light and sound - activate the windows | http://pobox.com/~warmerdam > and watch the world go round - Rush | Geospatial Programmer for Rent > > -- http://giscoder.blogspot.com/
_______________________________________________ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev