[geos-devel] problems with C/C++- getting warmer! (Reader Frees too
much?)
David Blasby
dblasby at refractions.net
Mon Apr 7 16:50:01 EDT 2003
Norman,
Could you give this little C++ code a try? Then try it again
without the "delete r; delete w;" lines commented out.
On my linux system, it works with the 2 lines commented out, but fails
with them actually in. More specficially it
fails if the reader (r) is deleted.
My bet is that the reader is freeing too much (perhaps the
PrecisionModel?). The difference is functinality is probably
how cygwin actually implements its deletes at the operating system
level. I know that solaris machines are really picky about
memory allocations and deletions - more so than linux machines. Perhaps
linux is more picky than cygwin?
I'll look in the actual geos code, but I wanted to know what happens on
your system.
[dblasby at lion work_dave]$ g++ test.cpp -I/usr/local/include/geos -lgeos
; ./a.out
geom (WKTWriter first try (should work) ):POLYGON ((100.0000000000000000
200.0000000000000000, 100.0000000000000000 140.0000000000000000,
180.0000000000000000 140.0000000000000000, 180.0000000000000000
200.0000000000000000, 100.0000000000000000 200.0000000000000000))
geom (WKTWriter):POLYGON ((100.0000000000000000 200.0000000000000000,
100.0000000000000000 140.0000000000000000, 180.0000000000000000
140.0000000000000000, 180.0000000000000000 200.0000000000000000,
100.0000000000000000 200.0000000000000000))
[dblasby at lion work_dave]$ cat test.cpp
// g++ test.cpp -I/usr/local/include/geos -lgeos
#include "stdio.h"
#include "io.h"
int main(int argC, char* argV[])
{
Geometry *g = new Geometry;
WKTReader *r = new WKTReader(new GeometryFactory(new
PrecisionModel(),-1));
WKTWriter *w=new WKTWriter();
string wkt_out;
g = r->read("POLYGON((100 200,100 140,180 140,180 200,100 200))");
wkt_out = w->write(g) ;
cout << endl << "geom (WKTWriter first try (should work) ):"<<
wkt_out << endl;
//delete r; //uncommenting this will cause this program to
fail on linux machines.
//delete w;
w=new WKTWriter();
wkt_out = w->write(g) ;
cout << endl << "geom (WKTWriter):"<< wkt_out << endl;
}
More information about the geos-devel
mailing list