[gdal-dev] Resizing CPLErrorContext?

Even Rouault even.rouault at spatialys.com
Tue May 16 11:01:06 PDT 2017


On mardi 16 mai 2017 10:26:09 CEST Kurt Schwehr wrote:
> I now know this is referred to as the "struct hack."
> 
> This really is undefined behavior in the C++11 standard...  

Well, I don't think the hack is really needed and char szLastErrorMsg[] could be 
replaces by a char* pszLastErrorMsg that would be malloc'ated.
The current situation comes from the fact that originally no custom free function 
could be associated with a TLS member, but now that we have a
CPLSetTLSWithFreeFunc() we could use it to free the pszLastErrorMsg member 
before freeing the context.

(or use std::string if you prefer, but this code portion can be run under very low 
memory conditions, so great care is needed)

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20170516/c1475aa5/attachment-0001.html>


More information about the gdal-dev mailing list