[Gdal-dev] GDALClose vs delete
Frank Warmerdam
fwarmerdam at gmail.com
Wed Mar 9 12:54:08 EST 2005
On Wed, 9 Mar 2005 12:41:45 -0500, William Lyons
<wlyons at prologic-inc.com> wrote:
>
> Frank and List,
>
> The documentation for GDALClose() mention that it should be used for data
> sets opened with GDALOpenShared().
>
> And that C++ delete should be used for data sets opened with GDALOpen().
>
> But, which should be used to close datasets that are the product of a
> GDALCreate() or GDALCreateCopy() call?
William,
In theory a delete is fine for the results of GDALCreate() or
GDALCreateCopy(). However, you can also safely use
GDALClose() for all these, and I normally do. The special
issue with GDALOpenShared() is that GDALClose() first
dereferences the dataset and then deletes it if the reference
count has dropped to zero.
Also, in a windows build environment where different DLLs
have different heaps, using delete outside the DLL in which
the new took place can be very dangerous. So I also avoid
use of delete for that reason.
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