Hi,

Looking at the code of GDAL 2.0 (but also 1.x), I noticed that the OGRGeometry 
class (and the derived classes) do not respects the Rule of 3 : there is a 
destructor and no copy constructor or assignment operator. It seems to me that 
this may lead to memory leaks on OGRSpatialReference (for example when using 
std::vector<OGRPoint> and not std::vector<OGRPoint*>).
This is not an issue when using the C API because the clone() method is used.
Am I well understanding the API ? 

Various solutions exists:
1) defines private copy constructors and assignment operators (eg. libkml does 
this with a macro on each class: LIBKML_DISALLOW_EVIL_CONSTRUCTORS)
2) implements these methods, and manage poSRS the same way that clone()  does.
3) do nothing (and document it somewhere)

If needed I may open an issue and/or send a patch.

Best regards,
Simon HEGE
                                          
_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to