xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David_N_Bert...@lotus.com
Subject Re: deleting a XalanNode
Date Mon, 22 Jan 2001 01:17:35 GMT

Like I said in my previous response, if you created the XalanDocument
instance through XercesParserLiaison::createDocument() you _cannot _ delete
the instance yourself -- it is owned by the parser liaison.

If you created it like this:

XalanDocument*
myVeryOwnCreateDocument(const DOM_Document&  theDoc)
{
  return new XercesDocumentBridge(theDoc);
}

then you are responsible for deleting the document instance -- unless you
want a memory leak.

Under no circumstances can you delete a node that a document created.  As I
said in my previous response, they are owned by the document, and they are
not even created by a call to new, so you _cannot_ delete them.

Dave



                                                                                         
                         
                    "Lyle Coder"                                                         
                         
                    <x_coder@hotm        To:     <general@xml.apache.org>       
                                  
                    ail.com>             cc:     (bcc: David N Bertoni/CAM/Lotus)     
                            
                                         Subject:     Re: deleting a XalanNode           
                         
                    01/06/2001                                                           
                         
                    07:57 AM                                                             
                         
                    Please                                                               
                         
                    respond to                                                           
                         
                    general                                                              
                         
                                                                                         
                         
                                                                                         
                         



Hi,
The nodes are created using XalanDocument::createElement().  So can I just
delete the document root pointer and expect th eentore tree to be free'd
up?
Can I say delete node where node is a XalanDocument * created using
ParserLiaison::createDocument()

Thanks
Lyle
----- Original Message -----
From: <David_N_Bertoni@lotus.com>
To: <general@xml.apache.org>
Sent: Sunday, January 21, 2001 6:45 AM
Subject: Re: deleting a XalanNode


>
> I don't understand what you mean by the "XalanDom".  There is no such
> thing.  There is a collection of abstract base classes in the XalanDOM
> subsystem, but there is no implementation.
>
> If you are using an instance Xalan's XercesParserLiaison to wrap the
Xerces
> DOM, or you're using the XalanSourceTree, then you are not allowed to
> delete nodes that belong to a document.  The document owns the nodes and
> deletes them when the document itself is deleted.  The reason you're
> getting a set fault is because the nodes are not allocated by new, so
using
> delete results in undefined behavior.
>
> If you've created a document yourself, you are responsible for deleting
the
> document.  If you created it through a XercesParserLiaison instance, then
> that instance owns the document and will delete when it is reset, or it
> goes out of scope.
>
> Dave
>
>
>
>
>                     "Lyle Coder"
>                     <x_coder@hotm        To:     <general@xml.apache.org>
>                     ail.com>             cc:     (bcc: David N
Bertoni/CAM/Lotus)
>                                          Subject:     deleting a
XalanNode
>                     01/05/2001
>                     06:52 PM
>                     Please
>                     respond to
>                     general
>
>
>
>
>
> Hi,
> I have a function called xalan_free which walks the XalanDom in post
order
> freeing at the end of the walk like this:
>
> void xalan_free(XalanNode *node)
> {
>     if(node->hasChildren())
>         xalan_free(node->getFirstChild());
>
>     if (node->getNextSibling())
>         xalan_free(node->getNextSibling());
>
>     if (node->getNodeType() != XalanNode::DOCUMENT_NODE)
>         node->getParentNode()->removeChild(node);
>
>     delete node;
> }
>
> problem is I get a seg fault at the delete... can some one tell me what
I'm
> doing wrong?
>
> Thanks
> Lyle
>
> ---------------------------------------------------------------------
> In case of troubles, e-mail:     webmaster@xml.apache.org
> To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
> For additional commands, e-mail: general-help@xml.apache.org
>
>
>
>
>
>
> ---------------------------------------------------------------------
> In case of troubles, e-mail:     webmaster@xml.apache.org
> To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
> For additional commands, e-mail: general-help@xml.apache.org
>
>

---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org






Mime
View raw message