[gdal-dev] GDAL Raster Attribute Tables.
Even Rouault
even.rouault at mines-paris.org
Sun May 5 12:57:45 PDT 2013
Le dimanche 05 mai 2013 05:01:17, Sam Gillingham a écrit :
> Hi Even, Frank etc,
>
> I have updated the RFC to incorporate the comments from this thread.
>
> http://trac.osgeo.org/gdal/wiki/rfc40_enhanced_rat_support
>
> Let me know if there is anything else that needs to be addressed, or if I
> have missed anything.
Sam,
About "The application should use CSLDestroy when finished to deallocate all
the memory.", this can work, but requires the calling code to do that :
/* Allocate one more element for the NULL string marking the end of array */
char** papszRet = (char**) CPLMalloc(sizeof(char*) * (nLength + 1));
papszRet[nLength] = NULL;
poRAT->ValuesIO(GF_Read, iField, iStartRow, nLength, papszRet);
CSLDestroy(papszRet);
That of course assumes that ValueIO() will never set an element of the array
to NULL. If so, CSLDestroy() would stop destroying strings at the first
occurence of a NULL string in the array.
Another possibility would be :
char** papszRet = (char**) CPLMalloc(sizeof(char*) * nLength);
/* ValuesIO() is supposed to initialize all the elements to a valid value, */
/* at least to NULL even/especially if it fails */
poRAT->ValuesIO(GF_Read, iField, iStartRow, nLength, papszRet);
for(i = 0; i < nLength; i++)
CPLFree(papszRet[i]);
CPLFree(papszRet);
Even
More information about the gdal-dev
mailing list