libxml-raku / LibXML-raku

Raku bindings to the libxml2 native library
Artistic License 2.0
11 stars 5 forks source link

domNodeIsReferenced is over-checking #58

Closed dwarring closed 3 years ago

dwarring commented 3 years ago

The basic strategy to work out if a sub tree is referenced is to find the root then check if any nods in the tree can be referenced, What this function is actually doing is:

// scan siblings and children
for (cur = self; cur != NULL; cur = cur->next) {
    xmlNodePtr kids = cur->children;
    if (cur->_private != NULL
        || (kids != NULL && domNodeIsReferenced(kids))) {
    ...
   }

So its revisiting peers that have already been referenced check by its parents.

dwarring commented 3 years ago

Needs a simple refactor to only visit heck nodes at this point.

dwarring commented 3 years ago

It was actually under-checking after 286a717 - fortunately pick up when running tests through valigrind.

We do need to examine sibling nodes, but just once at the top level. Refixed with eed1ec1.