[gdal-dev] GDALClose MEM

Frank Warmerdam warmerdam at pobox.com
Fri Nov 12 16:02:22 EST 2010


Radim Blazek wrote:
> Hi,
> does the GDALClose function called for MEM driver call free() on the
> memory passed to the driver as DATAPOINTER param? If so, how to avoid
> it?

Radim,

Internally the driver tries to keep track of whether it owns the
referenced memory or not.  It looks like if you use a DATAPOINTER
parameter with either MEMDataset::Open() or ::AddBand() it assumes
the caller retains ownership of the memory.  If you call AddBand()
without a DATAPOINTER it will allocate it internally and take
responsibility for destroying it.

If you call the MEMRasterBand() constructor directly yourself (not
possible through the generic GDAL API) then you can pass in the flag
indicating whether the memory is owned or not.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent



More information about the gdal-dev mailing list