That should be:
char* p = node.getNodeValue().transcode();
std::string value(p);
delete [] p;
Since the pointer was allocated with new [], you must use delete [].
You can get away with delete p using Visual C++, but on other platforms,
your application will crash. The standard says the behavior is
"undefined," so play it safe and use the appropriate delete operator.
Dave
"Adams,
David" To: "'[EMAIL PROTECTED]'"
<dadae@allsta <[EMAIL PROTECTED]>
te.com> cc: (bcc: David N Bertoni/CAM/Lotus)
Subject: RE: getNodeValue().transcode() -
Explanation
06/18/2001
11:13 AM
Please
respond to
xerces-c-dev
A note of caution. I noticed one suggestion as this:
std::string value(node.getNodeValue().transcode());
This will cause a memory leak if you use this method. 'std::string' makes
it
own copy of the returned string and it's destructor does not delete the
char* returned by 'transcode()'. The caller (you in this case) is still
responsible for deleting the char* returned from the 'transcode()' call,
which will be difficult since you don't have a pointer to it with the above
method. If you wish to use 'std::string' try something like this instead:
char* p = node.getNodeValue().transcode();
std::string value(p);
delete p;
> -----Original Message-----
> From: XML Man [SMTP:[EMAIL PROTECTED]]
> Sent: Monday, June 18, 2001 9:01 AM
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: Re: getNodeValue().transcode() - Explanation
>
> If that is true, I am not to care about it anymore.
>
> Thank you very much.
> _______________________________________________________________________
> Tu correo gratuito en HispaVista - http://www.hispavista.com/altacorreo/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]