|
Who does free the char returned by getHTMLImageMap ? |
Posted by Stephan on May-20-2015 17:33 |
|
Hello there,
I am using CDC 5.1.1 for C/C++. When I call BaseChart::getHTMLImageMap(), I get the HTML image map as a const char *. Do I have to release that one, or is CDC taking care of it ?
Thanks for your help,
Stephan |
Re: Who does free the char returned by getHTMLImageMap ? |
Posted by Peter Kwan on May-21-2015 01:09 |
|
Hi Stephan,
ChartDirector will release it when the BaseChart object is deleted.
In ChartDirector, in general, if your code calls a "new XXX" (such as "new XYChart(...)"),
then your code needs to delete it. If your code does not call "new XXX", then your code
must not delete it. For the getHTMLImageMap, your code does not need to use "new" to
allocate the memory, so your code must not delete it. The object the provides the text to
you (that is, the BaseChart object) will delete it.
Note that in C++, the BaseChart object can reuse the memory for other things. This can
occur when your code calls a method of the BaseChart object. So the "const char *"
pointer returned from getHTMLImageMap should be used immediately (such as to pass to
CChartViewer::setImageMap). Please do not store the "const char *" pointer for future use.
If you must store the text for future use, please allocated your own memory to make a
copy. (The CChartViewer internally immediately makes a copy the image map and never
keeps a copy of the pointer.)
Hope this can help.
Regards
Peter Kwan |
|