fix a problem with previous patch to testapi.c Daniel

* gentest.py testapi.c: fix a problem with previous patch to
  testapi.c
Daniel
diff --git a/ChangeLog b/ChangeLog
index ec1f97f..e31b0ea 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Mon Jul  4 00:39:35 CEST 2005 Daniel Veillard <daniel@veillard.com>
+
+	* gentest.py testapi.c: fix a problem with previous patch to
+	  testapi.c
+
 Sun Jul  3 23:42:31 CEST 2005 Daniel Veillard <daniel@veillard.com>
 
 	* testapi.c tree.c: fixing a leak detected by testapi in 
diff --git a/gentest.py b/gentest.py
index e4ede36..465fdd7 100755
--- a/gentest.py
+++ b/gentest.py
@@ -254,6 +254,7 @@
    "xmlParseDocument": "if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;}",
    "xmlParseChunk": "if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;}",
    "xmlParseExtParsedEnt": "if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;}",
+   "xmlDOMWrapAdoptNode": "if ((node != NULL) && (node->parent == NULL)) {xmlUnlinkNode(node);xmlFreeNode(node);node = NULL;}",
 }
 
 modules = []
diff --git a/testapi.c b/testapi.c
index 2575239..79efe8e 100644
--- a/testapi.c
+++ b/testapi.c
@@ -519,10 +519,6 @@
 }
 static void des_xmlNodePtr(int no, xmlNodePtr val, int nr ATTRIBUTE_UNUSED) {
     if (no == 1) {
-        if ((val != NULL) && (val->parent == NULL)) {
-	    xmlUnlinkNode(val);
-	    xmlFreeNode(val);
-	}
         free_api_doc();
     } else if (val != NULL) {
         xmlUnlinkNode(val);
@@ -18933,6 +18929,7 @@
         options = gen_int(n_options, 5);
 
         ret_val = xmlDOMWrapAdoptNode(ctxt, sourceDoc, node, destDoc, destParent, options);
+        if ((node != NULL) && (node->parent == NULL)) {xmlUnlinkNode(node);xmlFreeNode(node);node = NULL;}
         desret_int(ret_val);
         call_tests++;
         des_xmlDOMWrapCtxtPtr(n_ctxt, ctxt, 0);