Alex Brown wrote:
>
> "NOTE: The returned buffer is dynamically allocated and is the
> responsibility of the caller to delete it when not longer needed."
>
> But what function should be used for deleting the buffer? There's no
> guarantee (is there?) that the delete[] I might be using properly
> corresponds to the new[] that Xerces has used.

Xerces uses an ordinary call to C++ new, hence your call to delete[] is
just fine. However, if you are on a Microsoft platform you must be very
careful to ensure that the system actually behaves as the C++ standard
specifies. Most importantly, the code that calls delete[] must use the
same C runtime DLL as the Xerces DLL. Usually, this requires linking with
xerces-c_1D.lib if your settings include "Debug Multithreaded DLL" (/MDd),
and link with xerces-c_1.lib (without the 'D') if your settings are
"Multithreaded DLL" (/MD).

> Shouldn't there be a static method XMLString::freeBuffer to do this
> safely?

This would have prevented some problems on Microsoft platforms for
programs that use multiple C runtimes, but using multiple C runtimes is
not a good idea anyway (it breaks standard C/C++ semantics, wastes
resources, and can cause subtle runtime problems).

Joachim

-- 
work:     [EMAIL PROTECTED]   (http://www.netacquire.com)
private:  [EMAIL PROTECTED]          (http://www.kraut.ca)


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to