hi! we are currently struggling with getting the php4-domxml module leak-free. we use libxml2 as the xml backend. we track every node we create inside of php4 and attach a php4-resource (the _private slot, obviously). one major obstacle currently is that that we do not get to know what and when libxml2 free's nodes inside; take the 'magical' XML_TEXT_NODE coalescence_with_free in xmlAddChild as an example for one reason for our headaches, b/c it magically invalidates the passed child node ;) we can attach custom data to _private but dont get informed if/when we should free them. i cooked up a patch that adds two api functions that lets our code catch each creation and destruction of nodes making the cleanup process a lot less painful and less leaking. xmlRegisterNodeDefault(xmlRegisterNodeFunc f) register the callback for "hey, there's a new node now" xmlDeregisterNodeDefault(xmlDeregisterNodeFunc f) register the callback for "hey, this node will be gone in a few ticks" register is called after the node is fully built. deregister is called before any further descruction commences. the patch touches these files: global.data | 2 + globals.c | 53 ++++++++++++++++++++++++++++++ include/libxml/globals.h | 27 +++++++++++++++ tree.c | 83 ++++++++++++++++++++++++++++++++++++++++++++--- 4 files changed, 161 insertions(+), 4 deletions(-) the patch is basic and incomplete. but made php4-domxml happy in a proof-of-concept hack. you should get the idea of what i had in mind. what do you think ? is there a way to get something like this into libxml2 ? with kind regards, -lukas
Attachment:
gnome-xml-20020524.diff
Description: gnome-xml-cvs-20020524.diff