Re: [xml] Curious Segmentation Fault



On Mon, Apr 05, 2004 at 11:49:39AM -0400, Daniel Veillard wrote:

Again, the main unit of memory allocation in libxml2 is the
document.

Suppose a subroutine returns a node enveloped in a temporary document
(instead of returning an unlinked node). Is it legal to move the node
into a different destination document?

import libxml2
tmp = libxml2.newDoc("1.0")
element = tmp.newChild(None, "test", None)
doc = libxml2.newDoc("1.0")
element.unlinkNode()
doc.addChild(element)
tmp.freeDoc()
doc.freeDoc()

This seems to work fine, but from your statement I have a nagging
suspicion this might be illegal. The unlinkNode() doc says, "unlink a
node from it's current context, the node is not freed". I can't find
information about where it is legal to relink.

It would be a blow to modularity if the only possibility were to
recursively copying the node into the destination document.

Thank you so much for your patience.

-- 
Anthony Carrico



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]