I haven't checked libgeos_c.h but I'm pretty sure that the ring
becomes owned by the polygon. Therefore you only need to call
GEOSGeom_destroy() once, passing in the polygon as the argument.

Again, check the comments in the header, but I think that the
GEOSCoordSeq s will become owned by the LinearRing, so destroying it
separately would also cause a memory violation; it will be cleaned up
when the parent linearring (or parent polygon!) is destroyed.

Hopefully that will point you in the right direction.

Homme

On Wed, Dec 27, 2006 at 01:54:50PM +0100, Jean-Claude Repetto wrote:
> Hello,
> 
> This is my first attempt to use the GEOS library, so I am probably doing
> something wrong.
> I just want to create a polygon and then to destroy it.
> 
>       initGEOS(NULL, NULL);   // GEOS initialization
>       GEOSCoordSeq s = GEOSCoordSeq_create(npoints, 2);
>       for (i=0; i<npoints; i++) {
>               GEOSCoordSeq_setX (s, i, X[i]);
>               GEOSCoordSeq_setY (s, i, Y[i]);
>       }
>       GEOSGeom ring = GEOSGeom_createLinearRing(s);
>       GEOSGeom polygon = GEOSGeom_createPolygon(ring, NULL, 0);
> 
>       GEOSGeom_destroy(polygon);
>       GEOSGeom_destroy(ring);
>       GEOSCoordSeq_destroy(s);
> 
>       finishGEOS();                   // Cleanup GEOS
> 
> 
> The polygon is destroyed, but there is a segfault when the ring is
> destroyed (same problem when the sequence is destroyed).
> 
> I have tested GEOS 2.2.3 and GEOS 3.0.0_RC3.
> 
> Any help would be appreciated.
> 
> Thanks,
> Jean-Claude
> 
> 
> _______________________________________________
> geos-devel mailing list
> geos-devel@geos.refractions.net
> http://geos.refractions.net/mailman/listinfo/geos-devel
> 

-- 
Homme Zwaagstra
GeoData Institute
University of Southampton


_______________________________________________
geos-devel mailing list
geos-devel@geos.refractions.net
http://geos.refractions.net/mailman/listinfo/geos-devel

Reply via email to