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 Sun, 21 Jan 2001 14:45:59 GMT

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






Mime
View raw message