You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Paul Burlumi <pa...@argogroup.com> on 2002/03/21 12:14:17 UTC
RE: IDOM memory model
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: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org