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