IMHO, in the best scenario, you should pass in the buffer yourself. This way you can optimzie whether the buffer is allocated on the stack or the heap. Also, you can control how you release the memory for the buffer, i.e. what particular allocator you are using etc.
On the other hand, the method where Xerces allocates the memory is the easiest, i.e. you don't have to make sure your buffer is big enough, etc. Take your pick. I prefer to use the first method, because we have issues with mixed allocators in our product, and it also allows me to optimize heap access. If your application is not sensitive to heap access (i.e. this could be an issue in certain heavily multithreaded server applications) and you do not have issues with different allocators being used then the second method is probably best, as it is the most convenient and allows you to let Xerces determine buffer size etc. Samar -----Original Message----- From: jalal [mailto:[EMAIL PROTECTED]] Sent: Tuesday, December 04, 2001 10:52 To: xerces-c-dev Subject: Use of Transcode... Hi All I notice that XMLString::Transcode(...) creates a buffer that the user must free up. Or the user can pass a buffer for the transcoder to use. Which is the better way of doing Transcoding? i.e.[pseudo code] char* res = XMLString::transcode( mystring ); // do something delete [] char; or char buff[BUFFSIZE]; XMLString::transcode( mystring, buff, BUFFSIZE ); How can I find out how large a buffer to use? Currently I'm just assuming double the size of mystring... Really my question is, what is considered best practise for converting strings in and out of an XML file. cheers jalal --------------------------------------------------------------------- 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]
