[gdal-dev] copying a GDALColorTable

Mateusz Loskot mateusz at loskot.net
Sun Nov 11 10:59:27 PST 2012


On 11 November 2012 18:22, Even Rouault <even.rouault at mines-paris.org> wrote:
> Le dimanche 11 novembre 2012 19:16:30, David Strip a écrit :
>> If I'm reading the docs right, there is no copy constructor or
>> assignment operator for a GDALColorTable.
>> If I use GDALColorTable::clone(), how do release the copy when I'm done?
>> Do I use CPLFree or can I use delete?
>
> delete should work, but the preferred way would be GDALDestroyColorTable() to
> avoid potential cross-heap issues on Windows in case your code and GDAL aren't
> built with the same compiler / compiler options.

IMO, for GDAL 2.0 the API could be improved and some symmetry
introduced. For example, for GDALColorTable::Clone()
two static methods could be added:

static GDALColorTable* GDALColorTable::Create(GDALPaletteInterp=GPI_RGB);
static void GDALColorTable::Destroy(GDALColorTable*);

And, similar approach in other classes.

Best regards,
-- 
Mateusz Loskot, http://mateusz.loskot.net


More information about the gdal-dev mailing list