[xml] Only through experimentation :o) XML and memory




This is a question specifically to Daniel, but thought it would be useful if posted publicly.

As proabably gathered from my previous posts, I have been experimenting with different schemes and node management with libxml2.

        Now, I am doing a lot of this in my code:

                        newNode = xmlNewDocText(cur_node->doc, "blah");
                        xmlReplaceNode(cur_node, newNode);
                        xmlFreeNode(cur_node);
                        cur_node = newNode;


Then right at the end, I have:

                        xmlFreeDoc(doc);


Being very pendantic (hence lots of trial and error - my code has to have *zero* memory leaks) I had an assumption that the 'newNode' above created with 'xmlNewDocText' would need to be cleared later, but from my leaks tests I see that 'xmlFreeDoc' takes care of any externally allocated nodes. I want to make sure my assumption is right, that 'xmlFreeDoc' will also deallocate/free any new nodes linked in to the doc?

I have to add that, after many weeks of extensively using libxml2, I have found it to be one of the best libraries/API's I have ever used. The documentation needs a few tweaks, though! ;o)


Regards,
                Jose.

--
life, n.: A whim of several billion cells to be you for a while.




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