[gdal-dev] Who really owns the OGRFeatureDefn returned by OGRLayer::GetLayerDefn()
Vincent Mora
vincent.mora at oslandia.com
Fri Feb 28 01:26:28 PST 2014
Hi,
OGRLayer::GetLayerDefn() doc says "The returned OGRFeatureDefn is owned by the OGRLayer,
and should not be modified or freed by the application."
But in alg/contour.cpp, in OGRContourWriter, the return value ofGetLayerDefn is used to
create a feature that apparently takes ownership of the returned OGRFeatureDefn. When this
feature is freed at the end ofOGRContourWriter, theOGRFeatureDefn is freed.
Am I missing something ?
For info, my implementation ofGetLayerDefn is:
OGRFeatureDefn * OGRWAsPLayer::GetLayerDefn()
{
return &oLayerDefn;
}
withoLayerDefn a member ofOGRWAsPLayer:
classOGRWAsPLayer: public OGRLayer
{
...
OGRFeatureDefn oLayerDefn;
...
};
Everything works fine if I replaceGetLayerDefn by:
OGRFeatureDefn * OGRWAsPLayer::GetLayerDefn()
{
return oLayerDefn.Clone();
}
but cloning like that is not what should be done according to the doc.
Note that the xls driver creates a new "dummy"OGRFeatureDefn in its implementation
ofGetLayerDefn.
More information about the gdal-dev
mailing list