Regarding #2 (the direction I'd lean), does GetRefCount() need to be a public method?
Dan On Tue, Oct 21, 2025 at 1:08 PM Even Rouault via gdal-dev < [email protected]> wrote: > > > Encapsulating the object into a wrapper when returning the object to a > > language with automatic GC. > > > > If I don't do this, I will have to keep a reference to the layer or > > the feature. Or clone it. > > I see different options: > > 1) we revert that change. Downside: users may believe that they can > modify the OGRFeatureDefn* instance, which can potentially cause crashes > if they are OGRFeature* based on it (that was the rationale for > const'ifying) > > 2) we make OGRFeatureDefn::Reference() and Dereference() const methods. > But that's a clear violation of const semantics, given that we have a > GetRefCount() and thus the observable state is modified, so not > something I'd be super keen doing > > 3) the caller of OGRFeature::GetDefnRef() takes responsibility for > const_cast'ing the const pointer to a non-const pointer. For the purpose > of just modifying the ref counter, that's fine. > > -- > http://www.spatialys.com > My software is free, but my time generally not. > > _______________________________________________ > gdal-dev mailing list > [email protected] > https://lists.osgeo.org/mailman/listinfo/gdal-dev >
_______________________________________________ gdal-dev mailing list [email protected] https://lists.osgeo.org/mailman/listinfo/gdal-dev
