[gdal-dev] [gdal 3.12beta1] OGRFeature::GetDefnRef now returns a const pointer

Momtchil Momtchev momtchil at momtchev.com
Tue Oct 21 09:58:03 PDT 2025


On 21/10/2025 18:53, Even Rouault wrote:
>>
>> In GDAL 3.12, OGRFeature::GetDefnRef now returns a const pointer. 
>> This means that calling Reference() or Dereference() is no longer 
>> possible. Does this mean that this is now automatic?
>
> No. The ref count is modified when creating / destroying the layer 
> (when it is linked to a layer), or when creating / destroying features 
> using it.
>
> What would be the use case for manually incrementing/decrementing the 
> ref count of a OGRFeatureDefn* returned by OGRFeature::GetDefnRef() ? 

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.

-- 
Momtchil Momtchev <momtchil at momtchev.com>



More information about the gdal-dev mailing list