[gdal-dev] [gdal 3.12beta1] OGRFeature::GetDefnRef now returns a const pointer
Even Rouault
even.rouault at spatialys.com
Thu Oct 23 05:09:44 PDT 2025
>
> Ok, if whether its me const_casting or GDAL, this does not change the
> basic problem:
>
> Is incrementing the reference counter of a const object an allowed
> operation?
>
I'd say, if we were purely pedantic, no, but we might decide to derogate
from that, with warnings in the documentation. I'm still undecided about
the best course of action. I guess I'll talk about that in the
maintainer meeting in a few miutes.
>
> What happens if the Dataset or the Layer containing a returned const
> SpatialReference that has a positive reference count is destroyed?
If the ref count is just one, then destroying the layer will cause the
counter of the SpatialReference to drop by zero and be destroyed. If it
is more than one, then the life-time of the SpatialReference instance
will go beyond the container life-time.
>
> Same goes for OGRFeatureDefn and OGRFieldDefn of course, but at the
> moment my problem is especially with OGRSpatialReference.
Same as above
--
http://www.spatialys.com
My software is free, but my time generally not.
More information about the gdal-dev
mailing list