[Gdal-dev] how to re-use a GDAL dataset name

Frank Warmerdam fwarmerdam at gmail.com
Wed Mar 16 00:16:25 EST 2005

On Tue, 15 Mar 2005 23:03:31 -0600, Xiaodong Zhang <zhang at aero.und.edu> wrote:
> Greetings,
> Trying to use one Gdal dataset name to open multiple images (one at a time).
> int main() {
> GDALDataset *dataset;
> GDALALLRegister();
> for(int i=0;i<num_of_images;i++){
>     dataset = (GDALDataset *) GDALOpen(img_name(i),GA_ReadOnly);
>     .......;
>     delete dataset;
> }
> This is not working, the programs hangs.


This should work in general, so there must be some specifics
of your case that is causing an issue.  

I will caution you that deleting a dataset does not work
properly if you aren't using MSVCRT (or the .net equiv) on
Win32.  That is, if you have seperate heaps for each DLL and
the .exe you can't use delete in your main program.  Instead
use GDALClose(). 

But I am guessing there is some problem with the particular
format driver or data files you are working with that is causing
heap corruption or some other problem.

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