> If things are being freed unintentionally, then there are not enough
> ruby to ruby cross-references to maintain integrity during mark and
> sweep.

I actually think this could be done, but an external hash table of  
ptr's of both ruby and libxml obj's must be setup/maintained and it's  
problematic and I'd strongly avoiding doing so at this time.  At one  
point in time I started down this path and I caved under the  
complexity of managing references for two different dependency models.

> However, using xmlCopyNode, it is possible to get a copy of
> the node without an association to the document and also libxml2
> handles propagation of namespaces.

Exactly.  I went to great lengths initially to avoid this and am now  
of the opinion that copy'ing can't be practically avoided.  Setting a  
flag stating that a node is copied may not be a bad idea.

0) Create a series of hash tables:
   a) rubyCopiedNodes[ruby_node_obj's] = xmlNodeObjs
   b) rubyCopiedDocs[ruby_node_obj's] = xmlDocObjs
   c) libxmlCopiedNodes[xmlNodeObj] = ruby_node_obj;
   d) libxmlCopiedDocs[xmlDocObj] = ruby_doc_obj;
1) Make a copy of a node/doc
2) Make an entry in the above hash table for reference back to the  
original libxml obj
3) Make an entry in the above hash table for reference back to the  
original ruby obj
4) All node lookups that have the copy flag set resolve dependencies  
through the above hash table if the above returns something not  
null.  If null, returns null.

On deallocation of the object, remove the hash table entry.  Doing  
this only on copy is pretty easy to maintain and would give us a huge  
swatch of the originally intended/desired functionality.

> I intend to do this within a week. Post your warnings or wish me luck.

Warnings/suggestions posted above, but your plan is as good of one as  
exists - good luck!  -sc

--
Sean Chittenden
[EMAIL PROTECTED]


_______________________________________________
libxml-devel mailing list
libxml-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/libxml-devel

Reply via email to