Hi, Thanks for this important piece of information. I believe all the samples that I've seen so far use someCall(XMLString::transcode(...))
What about the "getDOMImplementation(...)" function? Does it dynamically allocate memory in the buffer? (Sorry for my ignorance -- I tried looking at the API for this, but couldn't find the info that I needed. I'm just trying to ensure that I don't end up with memory leaks in my application.) Thanks, Monica --- Jesse Pelton <[EMAIL PROTECTED]> wrote: > From the Xerces API documentation: > > XMLCh* XMLString::transcode ( const char *const > toTranscode ) [static] > > Transcodes a string to native code-page. > > NOTE: The returned buffer is dynamically allocated > and is the > responsibility of > the caller to delete it when not longer needed. > You can call > XMLString::release to > release this returned buffer. > > So every time you call transcode(), you should be > saving the returned > pointer in order to release its memory. The > following will leak the > memory allocated by transcode(): > > someCall(XMLString::transcode("some string")); > > If the examples really use this idiom, something is > wrong, either in the > documentation (which I believe to be correct) or in > the samples. > > ________________________________ > > From: Monica Lau [mailto:[EMAIL PROTECTED] > Sent: Thursday, April 08, 2004 11:43 PM > To: [EMAIL PROTECTED] > Subject: Re: DOMWriter Questions > > > Hi all, > > Thanks for all your responses. In the following > code snippet > (taken from DOMCreation and from DOMPrint), I just > want to make sure > that I've deleted all the memory approriately. Does > the > "getDOMImplementation()" function allocate memory on > the heap? (I've > looked at the online documentation, but couldn't > find much about this.) > > > Thanks again for your time and help. > > Regards, > Monica > > > DOMImplementation *impl = > > DOMImplementationRegistry::getDOMImplementation(XMLString::transcode("Co > re")); > > DOMDocument *mydoc = > > impl->createDocument(0,XMLString::transcode("company"),0); > DOMElement *rootElem = mydoc->getDocumentElement(); > DOMElement *prodElem = > > mydoc->createElement(XMLString::transcode("product")); > rootElem->appendChild(prodElem); > DOMText *prodDataVal = > > mydoc->createTextNode(XMLString::transcode("Xerces-C")); > prodElem->appendChild(prodDataVal); > > DOMWriter *writer = impl->createDOMWriter(); > cout << > XMLString::transcode(writer->writeToString(*mydoc)) > << > endl; > > // Delete Memory > writer->release(); > mydoc->release(); > delete impl; > > --------------------------------------------------------------------- > To unsubscribe, e-mail: > [EMAIL PROTECTED] > For additional commands, e-mail: > [EMAIL PROTECTED] > __________________________________ Do you Yahoo!? Yahoo! Small Business $15K Web Design Giveaway http://promotions.yahoo.com/design_giveaway/ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]