Martin, I am looking to do something very similar to that proposed by Jason, but looking at the current v1.7.0 code base I can't make sense of your code below. Won't calling delete on fDocument in giveDocument() delete the memory of what you are about to return? I think the code should look something like:
IDOM_Document* IDOMParser::giveDocument() { // We cannot enter here while a regular parse is in progress. if (fParseInProgress) ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); IDOM_Document* latestDoc = fDocument; fDocument = 0; this->reset(); return latestDoc; } This would also reset the IDOMParser into a consistent state. Have I missed some subtlety in your previous fragment or has the code base changed? Many thanks Paul Burlumi ------------------------------------------------------------------------ ----------------------------------------- > Hello Jason, you wrote > > > Is there some fundamental reason that the memory needs to be managed > > by the parser? Why can't it be managed by the document? > > I think this is merely a design issue: As the parser creates documents, it > should also be responsible of deleting them. Solely for this reason the > parser keeps a vector of all documents that it ever created. This list is > scrubbed by calling resetDocumentPool() or once the parser is deleted. > AFAIKS it would be no problem to add some method like 'giveDocument' to the > parser that removes the latest Document from the list and makes the caller > of this method responsible of deleting it. I'd suggest something like this: > > IDOM_Document* IDOMParser::giveDocument() > { > // We cannot enter here while a regular parse is in progress. > if (fParseInProgress) > ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); > > IDOM_Document* latestDoc = fDocument; > > delete fDocument; > fDocument = 0; > return latestDoc; > } > > regards, Martin --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]