[geos-devel] How to destroy PreparedGeometry object?

Mateusz Loskot mateusz at loskot.net
Mon Aug 11 19:10:45 EDT 2008


Martin Davis wrote:
> Ugh.
> 
> Sounds like we need a 
> PreparedGeometryFactory::destroyPreparedGeometry(PreparedGeometry *) 
> method, then - as per your suggestion.

or just

PreparedGeometryFactory::destroy(PreparedGeometry* )

as we have prepare() and create() but not preparePreparedGeometry etc.

(Actually, I would vote for renaming destroyGeometry() to just destroy() 
from the same reasons, but I understand it's likely impossible as it 
breaks public API)

> Does this same situation exist for all objects which might be allocated 
> on the heap?

Yes, it does exist for all objects that:
a) are allocated on the heap
b) and are returned outside GEOS, to user
c) and the ownership is transfered to user


The c) means that a user is responsible for destroying it.

> There's lots of classes in GEOS "below the Geometry level" 
> which might be used by a coder using the C++ API.  Perhaps there should 
> be a warning about this (in the non-existent FAQ?)

Yes, FAQ is good, but empty:

http://trac.osgeo.org/geos/wiki/FAQ

The explanation can be stolen from GDAL FAQ with some changes related to 
GEOS. Before I compile something, I need to find more examples of 
potentially dangerous places in GEOS.

Best regards
-- 
Mateusz Loskot, http://mateusz.loskot.net
Charter Member of OSGeo, http://osgeo.org


More information about the geos-devel mailing list