[gdal-dev] MEM Datasets

James Meyer jamesm at lantic.net
Tue Jul 13 06:10:19 EDT 2010


Hi

I am trying to use MEM (In-memory) datasets with GDAL.
However, on trying to close the dataset I get a segmentation fault.
The dataset is created successfully. The handle returned is valid and I 
am able to read and write to it.

Am I not supposed to try and close the handle or am I doing something 
else wrong?

The code is as follows:

//************************************************
  char filename[255];
  int datasize = 100 * 100 * (GDALGetDataTypeSize(GDT_Byte) / 8);

   void* data = malloc(datasize);
   sprintf(filename,
     "MEM:::DATAPOINTER=%p,PIXELS=%d,LINES=%d,BANDS=%d,DATATYPE=%s",
&data, 100, 100, 1, GDALGetDataTypeName(GDT_Byte));


   GDALDatasetH dst = GDALOpen(filename,GA_Update);
   GDALDataset* dest = (GDALDataset*) dst;

   if (! dest )
   {
      printf("Failed to open Dataset");
   }
   GDALClose(dst); //This fails
   free(data);
//**************************************************

Thanks

James


More information about the gdal-dev mailing list