more developments on the API testing more cleanups rebuilt Daniel

* gentest.py testapi.c: more developments on the API testing
* HTMLparser.c tree.c: more cleanups
* doc/*: rebuilt
Daniel
diff --git a/ChangeLog b/ChangeLog
index 491d988..12ed45d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Tue Nov  2 19:44:32 CET 2004 Daniel Veillard <daniel@veillard.com>
+
+	* gentest.py testapi.c: more developments on the API testing
+	* HTMLparser.c tree.c: more cleanups
+	* doc/*: rebuilt
+
 Tue Nov  2 15:49:34 CET 2004 Daniel Veillard <daniel@veillard.com>
 
 	* xmlmemory.c include/libxml/xmlmemory.h: adding xmlMemBlocks()
diff --git a/HTMLparser.c b/HTMLparser.c
index 6022ed5..3fe4b5d 100644
--- a/HTMLparser.c
+++ b/HTMLparser.c
@@ -109,13 +109,15 @@
     if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
         (ctxt->instate == XML_PARSER_EOF))
 	return;
-    ctxt->errNo = error;
+    if (ctxt != NULL)
+	ctxt->errNo = error;
     __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_HTML, error,
                     XML_ERR_ERROR, NULL, 0,
 		    (const char *) str1, (const char *) str2,
 		    NULL, 0, 0,
 		    msg, str1, str2);
-    ctxt->wellFormed = 0;
+    if (ctxt != NULL)
+	ctxt->wellFormed = 0;
 }
 
 /**
@@ -134,11 +136,13 @@
     if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
         (ctxt->instate == XML_PARSER_EOF))
 	return;
-    ctxt->errNo = error;
+    if (ctxt != NULL)
+	ctxt->errNo = error;
     __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_HTML, error,
                     XML_ERR_ERROR, NULL, 0, NULL, NULL,
 		    NULL, val, 0, msg, val);
-    ctxt->wellFormed = 0;
+    if (ctxt != NULL)
+	ctxt->wellFormed = 0;
 }
 
 /************************************************************************
@@ -394,13 +398,15 @@
      * to ISO-Latin-1 (if you don't like this policy, just declare the
      * encoding !)
      */
-    htmlParseErr(ctxt, XML_ERR_INVALID_ENCODING,
-		 "Input is not proper UTF-8, indicate encoding !\n",
-		 NULL, NULL);
-    if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) {
-	ctxt->sax->error(ctxt->userData, "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
+    {
+        char buffer[150];
+
+	snprintf(buffer, 149, "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
 			ctxt->input->cur[0], ctxt->input->cur[1],
 			ctxt->input->cur[2], ctxt->input->cur[3]);
+	htmlParseErr(ctxt, XML_ERR_INVALID_ENCODING,
+		     "Input is not proper UTF-8, indicate encoding !\n",
+		     BAD_CAST buffer, NULL);
     }
 
     ctxt->charset = XML_CHAR_ENCODING_8859_1; 
@@ -3018,6 +3024,12 @@
 htmlParseCharRef(htmlParserCtxtPtr ctxt) {
     int val = 0;
 
+    if ((ctxt == NULL) || (ctxt->input == NULL)) {
+	htmlParseErr(ctxt, XML_ERR_INTERNAL_ERROR,
+		     "htmlParseCharRef: context error\n",
+		     NULL, NULL);
+        return(0);
+    }
     if ((CUR == '&') && (NXT(1) == '#') &&
         ((NXT(2) == 'x') || NXT(2) == 'X')) {
 	SKIP(3);
@@ -3341,6 +3353,11 @@
     int meta = 0;
     int i;
 
+    if ((ctxt == NULL) || (ctxt->input == NULL)) {
+	htmlParseErr(ctxt, XML_ERR_INTERNAL_ERROR,
+		     "htmlParseStartTag: context error\n", NULL, NULL);
+	return;
+    }
     if (CUR != '<') return;
     NEXT;
 
@@ -3822,9 +3839,15 @@
     const htmlElemDesc * info;
     htmlParserNodeInfo node_info;
     const xmlChar *oldname;
-    int depth = ctxt->nameNr;
+    int depth;
     const xmlChar *oldptr;
 
+    if ((ctxt == NULL) || (ctxt->input == NULL)) {
+	htmlParseErr(ctxt, XML_ERR_INTERNAL_ERROR,
+		     "htmlParseStartTag: context error\n", NULL, NULL);
+	return;
+    }
+    depth = ctxt->nameNr;
     /* Capture start position */
     if (ctxt->record_info) {
         node_info.begin_pos = ctxt->input->consumed +
@@ -3947,8 +3970,13 @@
     xmlInitParser();
 
     htmlDefaultSAXHandlerInit();
-    ctxt->html = 1;
 
+    if ((ctxt == NULL) || (ctxt->input == NULL)) {
+	htmlParseErr(ctxt, XML_ERR_INTERNAL_ERROR,
+		     "htmlParseDocument: context error\n", NULL, NULL);
+	return(XML_ERR_INTERNAL_ERROR);
+    }
+    ctxt->html = 1;
     GROW;
     /*
      * SAX: beginning of the document processing.
@@ -5132,6 +5160,11 @@
 int
 htmlParseChunk(htmlParserCtxtPtr ctxt, const char *chunk, int size,
               int terminate) {
+    if ((ctxt == NULL) || (ctxt->input == NULL)) {
+	htmlParseErr(ctxt, XML_ERR_INTERNAL_ERROR,
+		     "htmlParseChunk: context error\n", NULL, NULL);
+	return(XML_ERR_INTERNAL_ERROR);
+    }
     if ((size > 0) && (chunk != NULL) && (ctxt->input != NULL) &&
         (ctxt->input->buf != NULL) && (ctxt->instate != XML_PARSER_EOF))  {
 	int base = ctxt->input->base - ctxt->input->buf->buffer->content;
@@ -5361,6 +5394,9 @@
     /* htmlCharEncoding enc; */
     xmlChar *content, *content_line = (xmlChar *) "charset=";
 
+    if (filename == NULL)
+        return(NULL);
+
     ctxt = htmlNewParserCtxt();
     if (ctxt == NULL) {
 	return(NULL);
@@ -5616,7 +5652,12 @@
 htmlCtxtReset(htmlParserCtxtPtr ctxt)
 {
     xmlParserInputPtr input;
-    xmlDictPtr dict = ctxt->dict;
+    xmlDictPtr dict;
+    
+    if (ctxt == NULL)
+        return;
+
+    dict = ctxt->dict;
 
     while ((input = inputPop(ctxt)) != NULL) { /* Non consuming */
         xmlFreeInputStream(input);
@@ -5696,6 +5737,9 @@
 int
 htmlCtxtUseOptions(htmlParserCtxtPtr ctxt, int options)
 {
+    if (ctxt == NULL)
+        return(-1);
+
     if (options & HTML_PARSE_NOWARNING) {
         ctxt->sax->warning = NULL;
         ctxt->vctxt.warning = NULL;
diff --git a/doc/APIchunk10.html b/doc/APIchunk10.html
index c5625ef..a107993 100644
--- a/doc/APIchunk10.html
+++ b/doc/APIchunk10.html
@@ -795,6 +795,7 @@
 </dd><dt>cur</dt><dd><a href="html/libxml-xpath.html#xmlXPathAxisFunc">xmlXPathAxisFunc</a><br />
 </dd><dt>currently</dt><dd><a href="html/libxml-schemasInternals.html#XML_SCHEMAS_INCLUDING_CONVERT_NS">XML_SCHEMAS_INCLUDING_CONVERT_NS</a><br />
 <a href="html/libxml-xmlmemory.html#xmlGcMemGet">xmlGcMemGet</a><br />
+<a href="html/libxml-xmlmemory.html#xmlMemBlocks">xmlMemBlocks</a><br />
 <a href="html/libxml-xmlmemory.html#xmlMemGet">xmlMemGet</a><br />
 <a href="html/libxml-xmlmemory.html#xmlMemUsed">xmlMemUsed</a><br />
 <a href="html/libxml-xmlIO.html#xmlOutputBufferCreateFilename">xmlOutputBufferCreateFilename</a><br />
diff --git a/doc/APIchunk12.html b/doc/APIchunk12.html
index 030c8f7..2e5756f 100644
--- a/doc/APIchunk12.html
+++ b/doc/APIchunk12.html
@@ -100,6 +100,8 @@
 <a href="html/libxml-encoding.html#isolat1ToUTF8">isolat1ToUTF8</a><br />
 <a href="html/libxml-encoding.html#xmlCharEncodingInputFunc">xmlCharEncodingInputFunc</a><br />
 <a href="html/libxml-encoding.html#xmlCharEncodingOutputFunc">xmlCharEncodingOutputFunc</a><br />
+</dd><dt>embedded</dt><dd><a href="html/libxml-valid.html#XML_CTXT_FINISH_DTD_0">XML_CTXT_FINISH_DTD_0</a><br />
+<a href="html/libxml-valid.html#XML_CTXT_FINISH_DTD_1">XML_CTXT_FINISH_DTD_1</a><br />
 </dd><dt>emitted</dt><dd><a href="html/libxml-xmlerror.html#xmlSetGenericErrorFunc">xmlSetGenericErrorFunc</a><br />
 </dd><dt>empty-element</dt><dd><a href="html/libxml-parserInternals.html#xmlParseStartTag">xmlParseStartTag</a><br />
 </dd><dt>enable</dt><dd><a href="html/libxml-catalog.html#xmlCatalogSetDebug">xmlCatalogSetDebug</a><br />
diff --git a/doc/APIchunk13.html b/doc/APIchunk13.html
index 19d36a9..1f22598 100644
--- a/doc/APIchunk13.html
+++ b/doc/APIchunk13.html
@@ -141,6 +141,8 @@
 <a href="html/libxml-parser.html#xmlCreatePushParserCtxt">xmlCreatePushParserCtxt</a><br />
 <a href="html/libxml-xmlstring.html#xmlUTF8Strpos">xmlUTF8Strpos</a><br />
 </dd><dt>field</dt><dd><a href="html/libxml-parser.html#XML_COMPLETE_ATTRS">XML_COMPLETE_ATTRS</a><br />
+<a href="html/libxml-valid.html#XML_CTXT_FINISH_DTD_0">XML_CTXT_FINISH_DTD_0</a><br />
+<a href="html/libxml-valid.html#XML_CTXT_FINISH_DTD_1">XML_CTXT_FINISH_DTD_1</a><br />
 <a href="html/libxml-parser.html#XML_DETECT_IDS">XML_DETECT_IDS</a><br />
 <a href="html/libxml-parser.html#XML_SKIP_IDS">XML_SKIP_IDS</a><br />
 <a href="html/libxml-parserInternals.html#xmlParseMisc">xmlParseMisc</a><br />
@@ -182,6 +184,8 @@
 <a href="html/libxml-nanohttp.html#xmlNanoHTTPScanProxy">xmlNanoHTTPScanProxy</a><br />
 </dd><dt>finds</dt><dd><a href="html/libxml-tree.html#xmlSearchNs">xmlSearchNs</a><br />
 <a href="html/libxml-tree.html#xmlSearchNsByHref">xmlSearchNsByHref</a><br />
+</dd><dt>finishDtd</dt><dd><a href="html/libxml-valid.html#XML_CTXT_FINISH_DTD_0">XML_CTXT_FINISH_DTD_0</a><br />
+<a href="html/libxml-valid.html#XML_CTXT_FINISH_DTD_1">XML_CTXT_FINISH_DTD_1</a><br />
 </dd><dt>finished</dt><dd><a href="html/libxml-valid.html#_xmlValidCtxt">_xmlValidCtxt</a><br />
 <a href="html/libxml-parser.html#xmlCleanupParser">xmlCleanupParser</a><br />
 <a href="html/libxml-parserInternals.html#xmlSkipBlankChars">xmlSkipBlankChars</a><br />
diff --git a/doc/APIchunk15.html b/doc/APIchunk15.html
index 31bb8f1..41093c0 100644
--- a/doc/APIchunk15.html
+++ b/doc/APIchunk15.html
@@ -395,27 +395,6 @@
 <a href="html/libxml-tree.html#xmlNewPI">xmlNewPI</a><br />
 <a href="html/libxml-SAX2.html#xmlSAX2ProcessingInstruction">xmlSAX2ProcessingInstruction</a><br />
 </dd><dt>insufficient</dt><dd><a href="html/libxml-uri.html#xmlCanonicPath">xmlCanonicPath</a><br />
-</dd><dt>int</dt><dd><a href="html/libxml-parser.html#_xmlParserCtxt">_xmlParserCtxt</a><br />
-<a href="">c</a><br />
-<a href="html/libxml-SAX.html#getColumnNumber">getColumnNumber</a><br />
-<a href="html/libxml-SAX.html#getLineNumber">getLineNumber</a><br />
-<a href="html/libxml-HTMLparser.html#htmlHandleOmittedElem">htmlHandleOmittedElem</a><br />
-<a href="html/libxml-HTMLparser.html#htmlParseCharRef">htmlParseCharRef</a><br />
-<a href="html/libxml-parserInternals.html#xmlIsLetter">xmlIsLetter</a><br />
-<a href="html/libxml-parser.html#xmlKeepBlanksDefault">xmlKeepBlanksDefault</a><br />
-<a href="html/libxml-parser.html#xmlLineNumbersDefault">xmlLineNumbersDefault</a><br />
-<a href="html/libxml-xmlmemory.html#xmlMallocAtomicLoc">xmlMallocAtomicLoc</a><br />
-<a href="html/libxml-xmlmemory.html#xmlMallocLoc">xmlMallocLoc</a><br />
-<a href="html/libxml-xmlmemory.html#xmlMemUsed">xmlMemUsed</a><br />
-<a href="html/libxml-parserInternals.html#xmlParseCharData">xmlParseCharData</a><br />
-<a href="html/libxml-parserInternals.html#xmlParseCharRef">xmlParseCharRef</a><br />
-<a href="html/libxml-parser.html#xmlPedanticParserDefault">xmlPedanticParserDefault</a><br />
-<a href="html/libxml-xmlmemory.html#xmlReallocLoc">xmlReallocLoc</a><br />
-<a href="html/libxml-SAX2.html#xmlSAX2GetColumnNumber">xmlSAX2GetColumnNumber</a><br />
-<a href="html/libxml-SAX2.html#xmlSAX2GetLineNumber">xmlSAX2GetLineNumber</a><br />
-<a href="html/libxml-debugXML.html#xmlShellCmd">xmlShellCmd</a><br />
-<a href="html/libxml-tree.html#xmlSplitQName3">xmlSplitQName3</a><br />
-<a href="html/libxml-parser.html#xmlSubstituteEntitiesDefault">xmlSubstituteEntitiesDefault</a><br />
 </dd><dt>integer</dt><dd><a href="html/libxml-xmlstring.html#xmlStrcasecmp">xmlStrcasecmp</a><br />
 <a href="html/libxml-xmlstring.html#xmlStrcmp">xmlStrcmp</a><br />
 <a href="html/libxml-xmlstring.html#xmlStrncasecmp">xmlStrncasecmp</a><br />
diff --git a/doc/APIchunk21.html b/doc/APIchunk21.html
index 13d61f5..e36896a 100644
--- a/doc/APIchunk21.html
+++ b/doc/APIchunk21.html
@@ -399,7 +399,8 @@
 </dd><dt>represented</dt><dd><a href="html/libxml-parserInternals.html#xmlParseCharData">xmlParseCharData</a><br />
 <a href="html/libxml-xpathInternals.html#xmlXPathStringFunction">xmlXPathStringFunction</a><br />
 </dd><dt>represented:</dt><dd><a href="html/libxml-HTMLparser.html#_htmlElemDesc">_htmlElemDesc</a><br />
-</dd><dt>representing</dt><dd><a href="html/libxml-xmlmemory.html#xmlMemUsed">xmlMemUsed</a><br />
+</dd><dt>representing</dt><dd><a href="html/libxml-xmlmemory.html#xmlMemBlocks">xmlMemBlocks</a><br />
+<a href="html/libxml-xmlmemory.html#xmlMemUsed">xmlMemUsed</a><br />
 </dd><dt>request</dt><dd><a href="html/libxml-xmlIO.html#xmlIOHTTPOpenW">xmlIOHTTPOpenW</a><br />
 <a href="html/libxml-nanohttp.html#xmlNanoHTTPMethod">xmlNanoHTTPMethod</a><br />
 <a href="html/libxml-nanohttp.html#xmlNanoHTTPMethodRedir">xmlNanoHTTPMethodRedir</a><br />
diff --git a/doc/APIchunk26.html b/doc/APIchunk26.html
index bfde6d1..1f4f8d7 100644
--- a/doc/APIchunk26.html
+++ b/doc/APIchunk26.html
@@ -292,6 +292,8 @@
 </dd><dt>xmlParseFile</dt><dd><a href="html/libxml-catalog.html#xmlParseCatalogFile">xmlParseCatalogFile</a><br />
 </dd><dt>xmlParseNamespace:</dt><dd><a href="html/libxml-parserInternals.html#xmlParseNamespace">xmlParseNamespace</a><br />
 </dd><dt>xmlParseURI</dt><dd><a href="html/libxml-uri.html#xmlURIEscape">xmlURIEscape</a><br />
+</dd><dt>xmlParserCtxt</dt><dd><a href="html/libxml-valid.html#XML_CTXT_FINISH_DTD_0">XML_CTXT_FINISH_DTD_0</a><br />
+<a href="html/libxml-valid.html#XML_CTXT_FINISH_DTD_1">XML_CTXT_FINISH_DTD_1</a><br />
 </dd><dt>xmlParserCtxtPtr</dt><dd><a href="html/libxml-parser.html#xmlNewParserCtxt">xmlNewParserCtxt</a><br />
 <a href="html/libxml-xmlwriter.html#xmlNewTextWriterPushParser">xmlNewTextWriterPushParser</a><br />
 </dd><dt>xmlParserError</dt><dd><a href="html/libxml-xmlerror.html#_xmlError">_xmlError</a><br />
diff --git a/doc/APIchunk5.html b/doc/APIchunk5.html
index dbed0af..d3cc136 100644
--- a/doc/APIchunk5.html
+++ b/doc/APIchunk5.html
@@ -190,6 +190,7 @@
 </dd><dt>Provides</dt><dd><a href="html/libxml-SAX.html#getPublicId">getPublicId</a><br />
 <a href="html/libxml-SAX.html#getSystemId">getSystemId</a><br />
 <a href="html/libxml-xmlmemory.html#xmlGcMemGet">xmlGcMemGet</a><br />
+<a href="html/libxml-xmlmemory.html#xmlMemBlocks">xmlMemBlocks</a><br />
 <a href="html/libxml-xmlmemory.html#xmlMemGet">xmlMemGet</a><br />
 <a href="html/libxml-xmlmemory.html#xmlMemUsed">xmlMemUsed</a><br />
 <a href="html/libxml-nanohttp.html#xmlNanoHTTPContentLength">xmlNanoHTTPContentLength</a><br />
diff --git a/doc/APIchunk6.html b/doc/APIchunk6.html
index a760e36..668cd2d 100644
--- a/doc/APIchunk6.html
+++ b/doc/APIchunk6.html
@@ -440,7 +440,9 @@
 <a href="html/libxml-xpathInternals.html#xmlXPathNodeSetSort">xmlXPathNodeSetSort</a><br />
 </dd><dt>SpacingModifierLetters</dt><dd><a href="html/libxml-xmlunicode.html#xmlUCSIsSpacingModifierLetters">xmlUCSIsSpacingModifierLetters</a><br />
 </dd><dt>Spec</dt><dd><a href="html/libxml-parserInternals.html#xmlParseStartTag">xmlParseStartTag</a><br />
-</dd><dt>Special</dt><dd><a href="html/libxml-parser.html#XML_SAX2_MAGIC">XML_SAX2_MAGIC</a><br />
+</dd><dt>Special</dt><dd><a href="html/libxml-valid.html#XML_CTXT_FINISH_DTD_0">XML_CTXT_FINISH_DTD_0</a><br />
+<a href="html/libxml-valid.html#XML_CTXT_FINISH_DTD_1">XML_CTXT_FINISH_DTD_1</a><br />
+<a href="html/libxml-parser.html#XML_SAX2_MAGIC">XML_SAX2_MAGIC</a><br />
 </dd><dt>Specials</dt><dd><a href="html/libxml-xmlunicode.html#xmlUCSIsSpecials">xmlUCSIsSpecials</a><br />
 </dd><dt>Speed</dt><dd><a href="html/libxml-parser.html#_xmlParserCtxt">_xmlParserCtxt</a><br />
 </dd><dt>Standalone</dt><dd><a href="html/libxml-parserInternals.html#xmlParseSDDecl">xmlParseSDDecl</a><br />
diff --git a/doc/APIchunk8.html b/doc/APIchunk8.html
index 443d438..f13f591 100644
--- a/doc/APIchunk8.html
+++ b/doc/APIchunk8.html
@@ -637,6 +637,7 @@
 <a href="html/libxml-xmlmemory.html#xmlReallocLoc">xmlReallocLoc</a><br />
 </dd><dt>areas</dt><dd><a href="html/libxml-xmlmemory.html#xmlGcMemGet">xmlGcMemGet</a><br />
 <a href="html/libxml-xmlmemory.html#xmlGcMemSetup">xmlGcMemSetup</a><br />
+<a href="html/libxml-xmlmemory.html#xmlMemBlocks">xmlMemBlocks</a><br />
 <a href="html/libxml-xmlmemory.html#xmlMemShow">xmlMemShow</a><br />
 </dd><dt>args</dt><dd><a href="html/libxml-xpathInternals.html#CHECK_ARITY">CHECK_ARITY</a><br />
 <a href="">x</a><br />
diff --git a/doc/APIchunk9.html b/doc/APIchunk9.html
index 7a05689..1a0c75b 100644
--- a/doc/APIchunk9.html
+++ b/doc/APIchunk9.html
@@ -162,6 +162,7 @@
 <a href="html/libxml-SAX.html#initdocbDefaultSAXHandler">initdocbDefaultSAXHandler</a><br />
 <a href="html/libxml-SAX.html#inithtmlDefaultSAXHandler">inithtmlDefaultSAXHandler</a><br />
 <a href="html/libxml-SAX.html#initxmlDefaultSAXHandler">initxmlDefaultSAXHandler</a><br />
+<a href="html/libxml-xmlmemory.html#xmlMemBlocks">xmlMemBlocks</a><br />
 <a href="html/libxml-xmlmemory.html#xmlMemDisplay">xmlMemDisplay</a><br />
 <a href="html/libxml-xmlmemory.html#xmlMemoryDump">xmlMemoryDump</a><br />
 </dd><dt>book1</dt><dd><a href="html/libxml-uri.html#xmlBuildRelativeURI">xmlBuildRelativeURI</a><br />
diff --git a/doc/APIfiles.html b/doc/APIfiles.html
index 3dc6559..e6ac90c 100644
--- a/doc/APIfiles.html
+++ b/doc/APIfiles.html
@@ -1433,7 +1433,9 @@
 <a href="html/libxml-uri.html#xmlURIEscapeStr">xmlURIEscapeStr</a><br />
 <a href="html/libxml-uri.html#xmlURIPtr">xmlURIPtr</a><br />
 <a href="html/libxml-uri.html#xmlURIUnescapeString">xmlURIUnescapeString</a><br />
-</p><h2><a name="valid" id="valid">Module valid</a>:</h2><p><a href="html/libxml-valid.html#_xmlValidCtxt">_xmlValidCtxt</a><br />
+</p><h2><a name="valid" id="valid">Module valid</a>:</h2><p><a href="html/libxml-valid.html#XML_CTXT_FINISH_DTD_0">XML_CTXT_FINISH_DTD_0</a><br />
+<a href="html/libxml-valid.html#XML_CTXT_FINISH_DTD_1">XML_CTXT_FINISH_DTD_1</a><br />
+<a href="html/libxml-valid.html#_xmlValidCtxt">_xmlValidCtxt</a><br />
 <a href="html/libxml-valid.html#xmlAddAttributeDecl">xmlAddAttributeDecl</a><br />
 <a href="html/libxml-valid.html#xmlAddElementDecl">xmlAddElementDecl</a><br />
 <a href="html/libxml-valid.html#xmlAddID">xmlAddID</a><br />
@@ -2407,6 +2409,7 @@
 <a href="html/libxml-xmlmemory.html#xmlMallocAtomicLoc">xmlMallocAtomicLoc</a><br />
 <a href="html/libxml-xmlmemory.html#xmlMallocFunc">xmlMallocFunc</a><br />
 <a href="html/libxml-xmlmemory.html#xmlMallocLoc">xmlMallocLoc</a><br />
+<a href="html/libxml-xmlmemory.html#xmlMemBlocks">xmlMemBlocks</a><br />
 <a href="html/libxml-xmlmemory.html#xmlMemDisplay">xmlMemDisplay</a><br />
 <a href="html/libxml-xmlmemory.html#xmlMemFree">xmlMemFree</a><br />
 <a href="html/libxml-xmlmemory.html#xmlMemGet">xmlMemGet</a><br />
diff --git a/doc/APIsymbols.html b/doc/APIsymbols.html
index 19a0caa..aff50ba 100644
--- a/doc/APIsymbols.html
+++ b/doc/APIsymbols.html
@@ -223,6 +223,8 @@
 <a href="html/libxml-xmlerror.html#XML_CHECK_X">XML_CHECK_X</a><br />
 <a href="html/libxml-tree.html#XML_COMMENT_NODE">XML_COMMENT_NODE</a><br />
 <a href="html/libxml-parser.html#XML_COMPLETE_ATTRS">XML_COMPLETE_ATTRS</a><br />
+<a href="html/libxml-valid.html#XML_CTXT_FINISH_DTD_0">XML_CTXT_FINISH_DTD_0</a><br />
+<a href="html/libxml-valid.html#XML_CTXT_FINISH_DTD_1">XML_CTXT_FINISH_DTD_1</a><br />
 <a href="html/libxml-parser.html#XML_DEFAULT_VERSION">XML_DEFAULT_VERSION</a><br />
 <a href="html/libxml-parser.html#XML_DETECT_IDS">XML_DETECT_IDS</a><br />
 <a href="html/libxml-tree.html#XML_DOCB_DOCUMENT_NODE">XML_DOCB_DOCUMENT_NODE</a><br />
@@ -2022,6 +2024,7 @@
 <a href="html/libxml-xmlmemory.html#xmlMallocAtomicLoc">xmlMallocAtomicLoc</a><br />
 <a href="html/libxml-xmlmemory.html#xmlMallocFunc">xmlMallocFunc</a><br />
 <a href="html/libxml-xmlmemory.html#xmlMallocLoc">xmlMallocLoc</a><br />
+<a href="html/libxml-xmlmemory.html#xmlMemBlocks">xmlMemBlocks</a><br />
 <a href="html/libxml-xmlmemory.html#xmlMemDisplay">xmlMemDisplay</a><br />
 <a href="html/libxml-xmlmemory.html#xmlMemFree">xmlMemFree</a><br />
 <a href="html/libxml-xmlmemory.html#xmlMemGet">xmlMemGet</a><br />
diff --git a/doc/html/libxml-valid.html b/doc/html/libxml-valid.html
index bc18015..e26d184 100644
--- a/doc/html/libxml-valid.html
+++ b/doc/html/libxml-valid.html
@@ -10,7 +10,7 @@
 </style><style type="text/css">
       div.deprecated pre.programlisting {border-style: double;border-color:red}
       pre.programlisting {border-style: double;background: #EECFA1}
-    </style><title>Module valid from libxml2</title></head><body bgcolor="#8b7765" text="#000000" link="#a06060" vlink="#000000"><table border="0" width="100%" cellpadding="5" cellspacing="0" align="center"><tr><td width="120"><a href="http://swpat.ffii.org/"><img src="../epatents.png" alt="Action against software patents" /></a></td><td width="180"><a href="http://www.gnome.org/"><img src="../gnome2.png" alt="Gnome2 Logo" /></a><a href="http://www.w3.org/Status"><img src="../w3c.png" alt="W3C Logo" /></a><a href="http://www.redhat.com/"><img src="../redhat.gif" alt="Red Hat Logo" /></a><div align="left"><a href="http://xmlsoft.org/"><img src="../Libxml2-Logo-180x168.gif" alt="Made with Libxml2 Logo" /></a></div></td><td><table border="0" width="90%" cellpadding="2" cellspacing="0" align="center" bgcolor="#000000"><tr><td><table width="100%" border="0" cellspacing="1" cellpadding="3" bgcolor="#fffacd"><tr><td align="center"><h1></h1><h2>Module valid from libxml2</h2></td></tr></table></td></tr></table></td></tr></table><table border="0" cellpadding="4" cellspacing="0" width="100%" align="center"><tr><td bgcolor="#8b7765"><table border="0" cellspacing="0" cellpadding="2" width="100%"><tr><td valign="top" width="200" bgcolor="#8b7765"><table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000"><tr><td><table width="100%" border="0" cellspacing="1" cellpadding="3"><tr><td colspan="1" bgcolor="#eecfa1" align="center"><center><b>API Menu</b></center></td></tr><tr><td bgcolor="#fffacd"><form action="../search.php" enctype="application/x-www-form-urlencoded" method="get"><input name="query" type="text" size="20" value="" /><input name="submit" type="submit" value="Search ..." /></form><ul><li><a style="font-weight:bold" href="../index.html">Main Menu</a></li><li><a style="font-weight:bold" href="../docs.html">Developer Menu</a></li><li><a style="font-weight:bold" href="../examples/index.html">Code Examples</a></li><li><a style="font-weight:bold" href="index.html">API Menu</a></li><li><a href="libxml-parser.html">Parser API</a></li><li><a href="libxml-tree.html">Tree API</a></li><li><a href="libxml-xmlreader.html">Reader API</a></li><li><a href="../guidelines.html">XML Guidelines</a></li><li><a href="../ChangeLog.html">ChangeLog</a></li></ul></td></tr></table><table width="100%" border="0" cellspacing="1" cellpadding="3"><tr><td colspan="1" bgcolor="#eecfa1" align="center"><center><b>API Indexes</b></center></td></tr><tr><td bgcolor="#fffacd"><ul><li><a href="../APIchunk0.html">Alphabetic</a></li><li><a href="../APIconstructors.html">Constructors</a></li><li><a href="../APIfunctions.html">Functions/Types</a></li><li><a href="../APIfiles.html">Modules</a></li><li><a href="../APIsymbols.html">Symbols</a></li></ul></td></tr></table><table width="100%" border="0" cellspacing="1" cellpadding="3"><tr><td colspan="1" bgcolor="#eecfa1" align="center"><center><b>Related links</b></center></td></tr><tr><td bgcolor="#fffacd"><ul><li><a href="http://mail.gnome.org/archives/xml/">Mail archive</a></li><li><a href="http://xmlsoft.org/XSLT/">XSLT libxslt</a></li><li><a href="http://phd.cs.unibo.it/gdome2/">DOM gdome2</a></li><li><a href="http://www.aleksey.com/xmlsec/">XML-DSig xmlsec</a></li><li><a href="ftp://xmlsoft.org/">FTP</a></li><li><a href="http://www.zlatkovic.com/projects/libxml/">Windows binaries</a></li><li><a href="http://garypennington.net/libxml2/">Solaris binaries</a></li><li><a href="http://www.zveno.com/open_source/libxml2xslt.html">MacOsX binaries</a></li><li><a href="http://sourceforge.net/projects/libxml2-pas/">Pascal bindings</a></li><li><a href="http://bugzilla.gnome.org/buglist.cgi?product=libxml2">Bug Tracker</a></li></ul></td></tr></table></td></tr></table></td><td valign="top" bgcolor="#8b7765"><table border="0" cellspacing="0" cellpadding="1" width="100%"><tr><td><table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000"><tr><td><table border="0" cellpadding="3" cellspacing="1" width="100%"><tr><td bgcolor="#fffacd"><table class="navigation" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle"><td><a accesskey="p" href="libxml-uri.html"><img src="left.png" width="24" height="24" border="0" alt="Prev" /></a></td><th align="left"><a href="libxml-uri.html">uri</a></th><td><a accesskey="u" href="index.html"><img src="up.png" width="24" height="24" border="0" alt="Up" /></a></td><th align="left"><a href="index.html">API documentation</a></th><td><a accesskey="h" href="../index.html"><img src="home.png" width="24" height="24" border="0" alt="Home" /></a></td><th align="center"><a href="../index.html">The XML C parser and toolkit of Gnome</a></th><th align="right"><a href="libxml-xinclude.html">xinclude</a></th><td><a accesskey="n" href="libxml-xinclude.html"><img src="right.png" width="24" height="24" border="0" alt="Next" /></a></td></tr></table><p>API for the DTD handling and the validity checking </p><h2>Table of Contents</h2><pre class="programlisting">Structure <a href="#xmlAttributeTable">xmlAttributeTable</a><br />struct _xmlHashTable
+    </style><title>Module valid from libxml2</title></head><body bgcolor="#8b7765" text="#000000" link="#a06060" vlink="#000000"><table border="0" width="100%" cellpadding="5" cellspacing="0" align="center"><tr><td width="120"><a href="http://swpat.ffii.org/"><img src="../epatents.png" alt="Action against software patents" /></a></td><td width="180"><a href="http://www.gnome.org/"><img src="../gnome2.png" alt="Gnome2 Logo" /></a><a href="http://www.w3.org/Status"><img src="../w3c.png" alt="W3C Logo" /></a><a href="http://www.redhat.com/"><img src="../redhat.gif" alt="Red Hat Logo" /></a><div align="left"><a href="http://xmlsoft.org/"><img src="../Libxml2-Logo-180x168.gif" alt="Made with Libxml2 Logo" /></a></div></td><td><table border="0" width="90%" cellpadding="2" cellspacing="0" align="center" bgcolor="#000000"><tr><td><table width="100%" border="0" cellspacing="1" cellpadding="3" bgcolor="#fffacd"><tr><td align="center"><h1></h1><h2>Module valid from libxml2</h2></td></tr></table></td></tr></table></td></tr></table><table border="0" cellpadding="4" cellspacing="0" width="100%" align="center"><tr><td bgcolor="#8b7765"><table border="0" cellspacing="0" cellpadding="2" width="100%"><tr><td valign="top" width="200" bgcolor="#8b7765"><table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000"><tr><td><table width="100%" border="0" cellspacing="1" cellpadding="3"><tr><td colspan="1" bgcolor="#eecfa1" align="center"><center><b>API Menu</b></center></td></tr><tr><td bgcolor="#fffacd"><form action="../search.php" enctype="application/x-www-form-urlencoded" method="get"><input name="query" type="text" size="20" value="" /><input name="submit" type="submit" value="Search ..." /></form><ul><li><a style="font-weight:bold" href="../index.html">Main Menu</a></li><li><a style="font-weight:bold" href="../docs.html">Developer Menu</a></li><li><a style="font-weight:bold" href="../examples/index.html">Code Examples</a></li><li><a style="font-weight:bold" href="index.html">API Menu</a></li><li><a href="libxml-parser.html">Parser API</a></li><li><a href="libxml-tree.html">Tree API</a></li><li><a href="libxml-xmlreader.html">Reader API</a></li><li><a href="../guidelines.html">XML Guidelines</a></li><li><a href="../ChangeLog.html">ChangeLog</a></li></ul></td></tr></table><table width="100%" border="0" cellspacing="1" cellpadding="3"><tr><td colspan="1" bgcolor="#eecfa1" align="center"><center><b>API Indexes</b></center></td></tr><tr><td bgcolor="#fffacd"><ul><li><a href="../APIchunk0.html">Alphabetic</a></li><li><a href="../APIconstructors.html">Constructors</a></li><li><a href="../APIfunctions.html">Functions/Types</a></li><li><a href="../APIfiles.html">Modules</a></li><li><a href="../APIsymbols.html">Symbols</a></li></ul></td></tr></table><table width="100%" border="0" cellspacing="1" cellpadding="3"><tr><td colspan="1" bgcolor="#eecfa1" align="center"><center><b>Related links</b></center></td></tr><tr><td bgcolor="#fffacd"><ul><li><a href="http://mail.gnome.org/archives/xml/">Mail archive</a></li><li><a href="http://xmlsoft.org/XSLT/">XSLT libxslt</a></li><li><a href="http://phd.cs.unibo.it/gdome2/">DOM gdome2</a></li><li><a href="http://www.aleksey.com/xmlsec/">XML-DSig xmlsec</a></li><li><a href="ftp://xmlsoft.org/">FTP</a></li><li><a href="http://www.zlatkovic.com/projects/libxml/">Windows binaries</a></li><li><a href="http://garypennington.net/libxml2/">Solaris binaries</a></li><li><a href="http://www.zveno.com/open_source/libxml2xslt.html">MacOsX binaries</a></li><li><a href="http://sourceforge.net/projects/libxml2-pas/">Pascal bindings</a></li><li><a href="http://bugzilla.gnome.org/buglist.cgi?product=libxml2">Bug Tracker</a></li></ul></td></tr></table></td></tr></table></td><td valign="top" bgcolor="#8b7765"><table border="0" cellspacing="0" cellpadding="1" width="100%"><tr><td><table border="0" cellspacing="0" cellpadding="1" width="100%" bgcolor="#000000"><tr><td><table border="0" cellpadding="3" cellspacing="1" width="100%"><tr><td bgcolor="#fffacd"><table class="navigation" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle"><td><a accesskey="p" href="libxml-uri.html"><img src="left.png" width="24" height="24" border="0" alt="Prev" /></a></td><th align="left"><a href="libxml-uri.html">uri</a></th><td><a accesskey="u" href="index.html"><img src="up.png" width="24" height="24" border="0" alt="Up" /></a></td><th align="left"><a href="index.html">API documentation</a></th><td><a accesskey="h" href="../index.html"><img src="home.png" width="24" height="24" border="0" alt="Home" /></a></td><th align="center"><a href="../index.html">The XML C parser and toolkit of Gnome</a></th><th align="right"><a href="libxml-xinclude.html">xinclude</a></th><td><a accesskey="n" href="libxml-xinclude.html"><img src="right.png" width="24" height="24" border="0" alt="Next" /></a></td></tr></table><p>API for the DTD handling and the validity checking </p><h2>Table of Contents</h2><pre class="programlisting">#define <a href="#XML_CTXT_FINISH_DTD_0">XML_CTXT_FINISH_DTD_0</a></pre><pre class="programlisting">#define <a href="#XML_CTXT_FINISH_DTD_1">XML_CTXT_FINISH_DTD_1</a></pre><pre class="programlisting">Structure <a href="#xmlAttributeTable">xmlAttributeTable</a><br />struct _xmlHashTable
 The content of this structure is not made public by the API.
 </pre><pre class="programlisting">Typedef <a href="libxml-valid.html#xmlAttributeTable">xmlAttributeTable</a> * <a name="xmlAttributeTablePtr" id="xmlAttributeTablePtr">xmlAttributeTablePtr</a>
 </pre><pre class="programlisting">Structure <a href="#xmlElementTable">xmlElementTable</a><br />struct _xmlHashTable
@@ -104,6 +104,8 @@
 void	<a href="#xmlValidityWarningFunc">xmlValidityWarningFunc</a>		(void * ctx, <br />					 const char * msg, <br />					 ... ...)
 </pre>
 <h2>Description</h2>
+<h3><a name="XML_CTXT_FINISH_DTD_0" id="XML_CTXT_FINISH_DTD_0"></a>Macro: XML_CTXT_FINISH_DTD_0</h3><pre>#define XML_CTXT_FINISH_DTD_0</pre><p>Special value for finishDtd field when embedded in an <a href="libxml-tree.html#xmlParserCtxt">xmlParserCtxt</a></p>
+<h3><a name="XML_CTXT_FINISH_DTD_1" id="XML_CTXT_FINISH_DTD_1"></a>Macro: XML_CTXT_FINISH_DTD_1</h3><pre>#define XML_CTXT_FINISH_DTD_1</pre><p>Special value for finishDtd field when embedded in an <a href="libxml-tree.html#xmlParserCtxt">xmlParserCtxt</a></p>
 <h3><a name="xmlAttributeTable" id="xmlAttributeTable">Structure xmlAttributeTable</a></h3><pre class="programlisting">Structure xmlAttributeTable<br />struct _xmlHashTable {
 The content of this structure is not made public by the API.
 }</pre><h3><a name="xmlElementTable" id="xmlElementTable">Structure xmlElementTable</a></h3><pre class="programlisting">Structure xmlElementTable<br />struct _xmlHashTable {
@@ -122,7 +124,7 @@
     int	nodeNr	: Depth of the parsing stack
     int	nodeMax	: Max depth of the parsing stack
     <a href="libxml-tree.html#xmlNodePtr">xmlNodePtr</a> *	nodeTab	: array of nodes
-    int	finishDtd	: finished validating the Dtd ?
+    unsigned int	finishDtd	: finished validating the Dtd ?
     <a href="libxml-tree.html#xmlDocPtr">xmlDocPtr</a>	doc	: the document
     int	valid	: temporary validity check result state s
     <a href="libxml-valid.html#xmlValidState">xmlValidState</a> *	vstate	: current state
diff --git a/doc/html/libxml-xmlmemory.html b/doc/html/libxml-xmlmemory.html
index 90f9167..23d3416 100644
--- a/doc/html/libxml-xmlmemory.html
+++ b/doc/html/libxml-xmlmemory.html
@@ -30,6 +30,7 @@
 void *	<a href="#xmlMallocFunc">xmlMallocFunc</a>			(size_t size)
 </pre>
 <pre class="programlisting">void *	<a href="#xmlMallocLoc">xmlMallocLoc</a>			(size_t size, <br />					 const char * file, <br />					 int line)</pre>
+<pre class="programlisting">int	<a href="#xmlMemBlocks">xmlMemBlocks</a>			(void)</pre>
 <pre class="programlisting">void	<a href="#xmlMemDisplay">xmlMemDisplay</a>			(FILE * fp)</pre>
 <pre class="programlisting">void	<a href="#xmlMemFree">xmlMemFree</a>			(void * ptr)</pre>
 <pre class="programlisting">int	<a href="#xmlMemGet">xmlMemGet</a>			(<a href="libxml-xmlmemory.html#xmlFreeFunc">xmlFreeFunc</a> * freeFunc, <br />					 <a href="libxml-xmlmemory.html#xmlMallocFunc">xmlMallocFunc</a> * mallocFunc, <br />					 <a href="libxml-xmlmemory.html#xmlReallocFunc">xmlReallocFunc</a> * reallocFunc, <br />					 <a href="libxml-xmlmemory.html#xmlStrdupFunc">xmlStrdupFunc</a> * strdupFunc)</pre>
@@ -68,7 +69,9 @@
 </pre><p>Signature for a malloc() implementation.</p><div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>size</tt></i>:</span></td><td>the size requested in bytes</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>a pointer to the newly allocated block or NULL in case of error.</td></tr></tbody></table></div><br />
 <h3><a name="xmlMallocLoc" id="xmlMallocLoc"></a>Function: xmlMallocLoc</h3><pre class="programlisting">void *	xmlMallocLoc			(size_t size, <br />					 const char * file, <br />					 int line)<br />
 </pre><p>a malloc() equivalent, with logging of the allocation info.</p>
-<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>size</tt></i>:</span></td><td>an int specifying the size in byte to allocate.</td></tr><tr><td><span class="term"><i><tt>file</tt></i>:</span></td><td>the file name or NULL</td></tr><tr><td><span class="term"><i><tt>line</tt></i>:</span></td><td>the line number</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>a pointer to the allocated area or NULL in case of lack of memory.</td></tr></tbody></table></div><h3><a name="xmlMemDisplay" id="xmlMemDisplay"></a>Function: xmlMemDisplay</h3><pre class="programlisting">void	xmlMemDisplay			(FILE * fp)<br />
+<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>size</tt></i>:</span></td><td>an int specifying the size in byte to allocate.</td></tr><tr><td><span class="term"><i><tt>file</tt></i>:</span></td><td>the file name or NULL</td></tr><tr><td><span class="term"><i><tt>line</tt></i>:</span></td><td>the line number</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>a pointer to the allocated area or NULL in case of lack of memory.</td></tr></tbody></table></div><h3><a name="xmlMemBlocks" id="xmlMemBlocks"></a>Function: xmlMemBlocks</h3><pre class="programlisting">int	xmlMemBlocks			(void)<br />
+</pre><p>Provides the number of memory areas currently allocated</p>
+<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>an int representing the number of blocks</td></tr></tbody></table></div><h3><a name="xmlMemDisplay" id="xmlMemDisplay"></a>Function: xmlMemDisplay</h3><pre class="programlisting">void	xmlMemDisplay			(FILE * fp)<br />
 </pre><p>show in-extenso the memory blocks allocated</p>
 <div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>fp</tt></i>:</span></td><td>a FILE descriptor used as the output file, if NULL, the result is written to the file .memorylist</td></tr></tbody></table></div><h3><a name="xmlMemFree" id="xmlMemFree"></a>Function: xmlMemFree</h3><pre class="programlisting">void	xmlMemFree			(void * ptr)<br />
 </pre><p></p>
diff --git a/doc/libxml2-api.xml b/doc/libxml2-api.xml
index 3da8dbe..8d24357 100644
--- a/doc/libxml2-api.xml
+++ b/doc/libxml2-api.xml
@@ -1557,6 +1557,8 @@
      <summary>The DTD validation</summary>
      <description>API for the DTD handling and the validity checking </description>
      <author>Daniel Veillard </author>
+     <exports symbol='XML_CTXT_FINISH_DTD_0' type='macro'/>
+     <exports symbol='XML_CTXT_FINISH_DTD_1' type='macro'/>
      <exports symbol='xmlElementTable' type='typedef'/>
      <exports symbol='xmlValidStatePtr' type='typedef'/>
      <exports symbol='xmlIDTablePtr' type='typedef'/>
@@ -2578,6 +2580,7 @@
      <exports symbol='xmlReallocFunc' type='function'/>
      <exports symbol='xmlMallocFunc' type='function'/>
      <exports symbol='xmlMemDisplay' type='function'/>
+     <exports symbol='xmlMemBlocks' type='function'/>
      <exports symbol='xmlGcMemSetup' type='function'/>
      <exports symbol='xmlMemShow' type='function'/>
      <exports symbol='xmlMemoryStrdup' type='function'/>
@@ -3751,6 +3754,12 @@
     <macro name='XML_COMPLETE_ATTRS' file='parser'>
       <info>Bit in the loadsubset context field to tell to do complete the elements attributes lists with the ones defaulted from the DTDs. Use it to initialize xmlLoadExtDtdDefaultValue.</info>
     </macro>
+    <macro name='XML_CTXT_FINISH_DTD_0' file='valid'>
+      <info>Special value for finishDtd field when embedded in an xmlParserCtxt</info>
+    </macro>
+    <macro name='XML_CTXT_FINISH_DTD_1' file='valid'>
+      <info>Special value for finishDtd field when embedded in an xmlParserCtxt</info>
+    </macro>
     <macro name='XML_DEFAULT_VERSION' file='parser'>
       <info>The default version of XML used: 1.0</info>
     </macro>
@@ -6125,7 +6134,7 @@
       <field name='nodeNr' type='int' info=' Depth of the parsing stack'/>
       <field name='nodeMax' type='int' info=' Max depth of the parsing stack'/>
       <field name='nodeTab' type='xmlNodePtr *' info=' array of nodes'/>
-      <field name='finishDtd' type='int' info=' finished validating the Dtd ?'/>
+      <field name='finishDtd' type='unsigned int' info=' finished validating the Dtd ?'/>
       <field name='doc' type='xmlDocPtr' info=' the document'/>
       <field name='valid' type='int' info=' temporary validity check result state state used for non-determinist content validation'/>
       <field name='vstate' type='xmlValidState *' info=' current state'/>
@@ -9914,6 +9923,10 @@
       <arg name='file' type='const char *' info='the file name or NULL'/>
       <arg name='line' type='int' info='the line number'/>
     </function>
+    <function name='xmlMemBlocks' file='xmlmemory'>
+      <info>Provides the number of memory areas currently allocated</info>
+      <return type='int' info='an int representing the number of blocks'/>
+    </function>
     <function name='xmlMemDisplay' file='xmlmemory'>
       <info>show in-extenso the memory blocks allocated</info>
       <return type='void'/>
diff --git a/doc/libxml2-refs.xml b/doc/libxml2-refs.xml
index f00a249..6c4e348 100644
--- a/doc/libxml2-refs.xml
+++ b/doc/libxml2-refs.xml
@@ -217,6 +217,8 @@
     <reference name='XML_CHECK_X' href='html/libxml-xmlerror.html#XML_CHECK_X'/>
     <reference name='XML_COMMENT_NODE' href='html/libxml-tree.html#XML_COMMENT_NODE'/>
     <reference name='XML_COMPLETE_ATTRS' href='html/libxml-parser.html#XML_COMPLETE_ATTRS'/>
+    <reference name='XML_CTXT_FINISH_DTD_0' href='html/libxml-valid.html#XML_CTXT_FINISH_DTD_0'/>
+    <reference name='XML_CTXT_FINISH_DTD_1' href='html/libxml-valid.html#XML_CTXT_FINISH_DTD_1'/>
     <reference name='XML_DEFAULT_VERSION' href='html/libxml-parser.html#XML_DEFAULT_VERSION'/>
     <reference name='XML_DETECT_IDS' href='html/libxml-parser.html#XML_DETECT_IDS'/>
     <reference name='XML_DOCB_DOCUMENT_NODE' href='html/libxml-tree.html#XML_DOCB_DOCUMENT_NODE'/>
@@ -2016,6 +2018,7 @@
     <reference name='xmlMallocAtomicLoc' href='html/libxml-xmlmemory.html#xmlMallocAtomicLoc'/>
     <reference name='xmlMallocFunc' href='html/libxml-xmlmemory.html#xmlMallocFunc'/>
     <reference name='xmlMallocLoc' href='html/libxml-xmlmemory.html#xmlMallocLoc'/>
+    <reference name='xmlMemBlocks' href='html/libxml-xmlmemory.html#xmlMemBlocks'/>
     <reference name='xmlMemDisplay' href='html/libxml-xmlmemory.html#xmlMemDisplay'/>
     <reference name='xmlMemFree' href='html/libxml-xmlmemory.html#xmlMemFree'/>
     <reference name='xmlMemGet' href='html/libxml-xmlmemory.html#xmlMemGet'/>
@@ -3467,6 +3470,8 @@
       <ref name='XML_CHECK_X'/>
       <ref name='XML_COMMENT_NODE'/>
       <ref name='XML_COMPLETE_ATTRS'/>
+      <ref name='XML_CTXT_FINISH_DTD_0'/>
+      <ref name='XML_CTXT_FINISH_DTD_1'/>
       <ref name='XML_DEFAULT_VERSION'/>
       <ref name='XML_DETECT_IDS'/>
       <ref name='XML_DOCB_DOCUMENT_NODE'/>
@@ -5302,6 +5307,7 @@
       <ref name='xmlMallocAtomicLoc'/>
       <ref name='xmlMallocFunc'/>
       <ref name='xmlMallocLoc'/>
+      <ref name='xmlMemBlocks'/>
       <ref name='xmlMemDisplay'/>
       <ref name='xmlMemFree'/>
       <ref name='xmlMemGet'/>
@@ -11185,6 +11191,8 @@
       <ref name='xmlURIUnescapeString'/>
     </file>
     <file name='valid'>
+      <ref name='XML_CTXT_FINISH_DTD_0'/>
+      <ref name='XML_CTXT_FINISH_DTD_1'/>
       <ref name='_xmlValidCtxt'/>
       <ref name='xmlAddAttributeDecl'/>
       <ref name='xmlAddElementDecl'/>
@@ -12173,6 +12181,7 @@
       <ref name='xmlMallocAtomicLoc'/>
       <ref name='xmlMallocFunc'/>
       <ref name='xmlMallocLoc'/>
+      <ref name='xmlMemBlocks'/>
       <ref name='xmlMemDisplay'/>
       <ref name='xmlMemFree'/>
       <ref name='xmlMemGet'/>
@@ -15725,6 +15734,7 @@
           <ref name='getPublicId'/>
           <ref name='getSystemId'/>
           <ref name='xmlGcMemGet'/>
+          <ref name='xmlMemBlocks'/>
           <ref name='xmlMemGet'/>
           <ref name='xmlMemUsed'/>
           <ref name='xmlNanoHTTPContentLength'/>
@@ -16396,6 +16406,8 @@
           <ref name='xmlParseStartTag'/>
         </word>
         <word name='Special'>
+          <ref name='XML_CTXT_FINISH_DTD_0'/>
+          <ref name='XML_CTXT_FINISH_DTD_1'/>
           <ref name='XML_SAX2_MAGIC'/>
         </word>
         <word name='Specials'>
@@ -17772,6 +17784,7 @@
         <word name='areas'>
           <ref name='xmlGcMemGet'/>
           <ref name='xmlGcMemSetup'/>
+          <ref name='xmlMemBlocks'/>
           <ref name='xmlMemShow'/>
         </word>
         <word name='args'>
@@ -18066,6 +18079,7 @@
           <ref name='initdocbDefaultSAXHandler'/>
           <ref name='inithtmlDefaultSAXHandler'/>
           <ref name='initxmlDefaultSAXHandler'/>
+          <ref name='xmlMemBlocks'/>
           <ref name='xmlMemDisplay'/>
           <ref name='xmlMemoryDump'/>
         </word>
@@ -19310,6 +19324,7 @@
         <word name='currently'>
           <ref name='XML_SCHEMAS_INCLUDING_CONVERT_NS'/>
           <ref name='xmlGcMemGet'/>
+          <ref name='xmlMemBlocks'/>
           <ref name='xmlMemGet'/>
           <ref name='xmlMemUsed'/>
           <ref name='xmlOutputBufferCreateFilename'/>
@@ -20172,6 +20187,10 @@
           <ref name='xmlCharEncodingInputFunc'/>
           <ref name='xmlCharEncodingOutputFunc'/>
         </word>
+        <word name='embedded'>
+          <ref name='XML_CTXT_FINISH_DTD_0'/>
+          <ref name='XML_CTXT_FINISH_DTD_1'/>
+        </word>
         <word name='emitted'>
           <ref name='xmlSetGenericErrorFunc'/>
         </word>
@@ -20769,6 +20788,8 @@
         </word>
         <word name='field'>
           <ref name='XML_COMPLETE_ATTRS'/>
+          <ref name='XML_CTXT_FINISH_DTD_0'/>
+          <ref name='XML_CTXT_FINISH_DTD_1'/>
           <ref name='XML_DETECT_IDS'/>
           <ref name='XML_SKIP_IDS'/>
           <ref name='xmlParseMisc'/>
@@ -20833,6 +20854,10 @@
           <ref name='xmlSearchNs'/>
           <ref name='xmlSearchNsByHref'/>
         </word>
+        <word name='finishDtd'>
+          <ref name='XML_CTXT_FINISH_DTD_0'/>
+          <ref name='XML_CTXT_FINISH_DTD_1'/>
+        </word>
         <word name='finished'>
           <ref name='_xmlValidCtxt'/>
           <ref name='xmlCleanupParser'/>
@@ -22095,29 +22120,6 @@
         <word name='insufficient'>
           <ref name='xmlCanonicPath'/>
         </word>
-        <word name='int'>
-          <ref name='_xmlParserCtxt'/>
-          <ref name='c'/>
-          <ref name='getColumnNumber'/>
-          <ref name='getLineNumber'/>
-          <ref name='htmlHandleOmittedElem'/>
-          <ref name='htmlParseCharRef'/>
-          <ref name='xmlIsLetter'/>
-          <ref name='xmlKeepBlanksDefault'/>
-          <ref name='xmlLineNumbersDefault'/>
-          <ref name='xmlMallocAtomicLoc'/>
-          <ref name='xmlMallocLoc'/>
-          <ref name='xmlMemUsed'/>
-          <ref name='xmlParseCharData'/>
-          <ref name='xmlParseCharRef'/>
-          <ref name='xmlPedanticParserDefault'/>
-          <ref name='xmlReallocLoc'/>
-          <ref name='xmlSAX2GetColumnNumber'/>
-          <ref name='xmlSAX2GetLineNumber'/>
-          <ref name='xmlShellCmd'/>
-          <ref name='xmlSplitQName3'/>
-          <ref name='xmlSubstituteEntitiesDefault'/>
-        </word>
         <word name='integer'>
           <ref name='xmlStrcasecmp'/>
           <ref name='xmlStrcmp'/>
@@ -25242,6 +25244,7 @@
           <ref name='_htmlElemDesc'/>
         </word>
         <word name='representing'>
+          <ref name='xmlMemBlocks'/>
           <ref name='xmlMemUsed'/>
         </word>
         <word name='request'>
@@ -28380,6 +28383,10 @@
         <word name='xmlParseURI'>
           <ref name='xmlURIEscape'/>
         </word>
+        <word name='xmlParserCtxt'>
+          <ref name='XML_CTXT_FINISH_DTD_0'/>
+          <ref name='XML_CTXT_FINISH_DTD_1'/>
+        </word>
         <word name='xmlParserCtxtPtr'>
           <ref name='xmlNewParserCtxt'/>
           <ref name='xmlNewTextWriterPushParser'/>
diff --git a/gentest.py b/gentest.py
index 7732d16..c74942c 100755
--- a/gentest.py
+++ b/gentest.py
@@ -21,6 +21,7 @@
 # Some function really need to be skipped for the tests.
 #
 skipped_functions = [ "xmlFdRead", "xmlReadFd", "xmlCtxtReadFd",
+                      "htmlFdRead", "htmlReadFd", "htmlCtxtReadFd",
                       "xmlCleanupParser" ]
 
 #
@@ -31,7 +32,33 @@
    "xmlSchemaInitTypes", "xmlNanoFTPProxy", "xmlNanoFTPScanProxy",
    "xmlNanoHTTPScanProxy", "xmlResetLastError", "xmlCatalogConvert",
    "xmlCatalogRemove", "xmlLoadCatalogs", "xmlCleanupCharEncodingHandlers",
-   "xmlInitCharEncodingHandlers" ]
+   "xmlInitCharEncodingHandlers", "xmlCatalogCleanup",
+   "htmlParseFile" # loads the catalogs
+]
+
+#
+# Extra code needed for some test cases
+#
+extra_post_call = {
+   "xmlAddChild": 
+       "if (ret_val == NULL) { xmlFreeNode(cur) ; cur = NULL ; }",
+   "xmlAddChildList": 
+       "if (ret_val == NULL) { xmlFreeNodeList(cur) ; cur = NULL ; }",
+   "xmlAddSibling":
+       "if (ret_val == NULL) { xmlFreeNode(elem) ; elem = NULL ; }",
+   "xmlAddNextSibling":
+       "if (ret_val == NULL) { xmlFreeNode(elem) ; elem = NULL ; }",
+   "xmlAddPrevSibling": 
+       "if (ret_val == NULL) { xmlFreeNode(elem) ; elem = NULL ; }",
+   "xmlDocSetRootElement": 
+       "if (doc == NULL) { xmlFreeNode(root) ; root = NULL ; }",
+   "xmlReplaceNode": 
+       """if ((old == NULL) || (old->parent == NULL)) {
+              xmlFreeNode(cur) ; cur = NULL ; }""",
+   "xmlTextMerge": 
+       """if ((first != NULL) && (first->type != XML_TEXT_NODE)) {
+              xmlFreeNode(second) ; second = NULL ; }""",
+}
 
 modules = []
 
@@ -106,6 +133,8 @@
     int ret;
     int blocks, mem;
 
+    xmlInitParser();
+
     LIBXML_TEST_VERSION
 
     xmlSetStructuredErrorFunc(NULL, structured_errors);
@@ -161,9 +190,12 @@
 # Provide the type generators and destructors for the parameters
 #
 
-def type_convert(str, name, info, module, function):
+def type_convert(str, name, info, module, function, pos):
     res = string.replace(str, " *", "_ptr")
     res = string.replace(res, " ", "_")
+    res = string.replace(res, "htmlNode", "xmlNode")
+    res = string.replace(res, "htmlDoc", "xmlDoc")
+    res = string.replace(res, "htmlParser", "xmlParser")
     if res == 'const_char_ptr':
         if string.find(name, "file") != -1 or \
            string.find(name, "uri") != -1 or \
@@ -179,11 +211,22 @@
 	    return('xmlNanoFTPCtxtPtr')
         if module == 'nanohttp' and name == 'ctx':
 	    return('xmlNanoHTTPCtxtPtr')
+    if res == 'xmlNodePtr' and pos != 0:
+        if (function == 'xmlAddChild' and pos == 2) or \
+	   (function == 'xmlAddChildList' and pos == 2) or \
+           (function == 'xmlAddNextSibling' and pos == 2) or \
+           (function == 'xmlAddSibling' and pos == 2) or \
+           (function == 'xmlDocSetRootElement' and pos == 2) or \
+           (function == 'xmlReplaceNode' and pos == 2) or \
+           (function == 'xmlTextMerge') or \
+	   (function == 'xmlAddPrevSibling' and pos == 2):
+	    return('xmlNodePtr_in');
         
     return res
 
 known_param_types = [ "int", "const_char_ptr", "const_xmlChar_ptr",
-   "xmlParserCtxtPtr", "xmlDocPtr", "filepath", "fileoutput" ];
+   "xmlParserCtxtPtr", "xmlDocPtr", "filepath", "fileoutput" ,
+   "xmlNodePtr", "xmlNodePtr_in" ];
 
 def is_known_param_type(name):
     for type in known_param_types:
@@ -265,9 +308,10 @@
         xmlFreeParserCtxt(val);
 }
 
-#define gen_nb_xmlDocPtr 2
+#define gen_nb_xmlDocPtr 3
 static xmlDocPtr gen_xmlDocPtr(int no) {
     if (no == 0) return(xmlNewDoc(BAD_CAST "1.0"));
+    if (no == 1) return(xmlReadMemory("<foo/>", 6, "test", NULL, 0));
     return(NULL);
 }
 static void des_xmlDocPtr(int no ATTRIBUTE_UNUSED, xmlDocPtr val) {
@@ -275,6 +319,27 @@
         xmlFreeDoc(val);
 }
 
+#define gen_nb_xmlNodePtr 2
+static xmlNodePtr gen_xmlNodePtr(int no) {
+    if (no == 0) return(xmlNewPI(BAD_CAST "test", NULL));
+    return(NULL);
+}
+static void des_xmlNodePtr(int no ATTRIBUTE_UNUSED, xmlNodePtr val) {
+    if (val != NULL) {
+        xmlUnlinkNode(val);
+        xmlFreeNode(val);
+    }
+}
+
+#define gen_nb_xmlNodePtr_in 3
+static xmlNodePtr gen_xmlNodePtr_in(int no) {
+    if (no == 0) return(xmlNewPI(BAD_CAST "test", NULL));
+    if (no == 0) return(xmlNewText(BAD_CAST "text"));
+    return(NULL);
+}
+static void des_xmlNodePtr_in(int no ATTRIBUTE_UNUSED, xmlNodePtr val ATTRIBUTE_UNUSED) {
+}
+
 """);
 
 #
@@ -364,13 +429,15 @@
     except:
         args = []
     t_args = []
+    n = 0
     for arg in args:
+        n = n + 1
         rtype = arg.xpathEval("string(@type)")
 	if rtype == 'void':
 	    break;
 	info = arg.xpathEval("string(@info)")
 	nam = arg.xpathEval("string(@name)")
-        type = type_convert(rtype, nam, info, module, name)
+        type = type_convert(rtype, nam, info, module, name, n)
 	if is_known_param_type(type) == 0:
 	    add_missing_type(type, name);
 	    no_gen = 1
@@ -384,7 +451,7 @@
     for ret in rets:
         rtype = ret.xpathEval("string(@type)")
 	info = ret.xpathEval("string(@info)")
-        type = type_convert(rtype, 'return', info, module, name)
+        type = type_convert(rtype, 'return', info, module, name, 0)
 	if rtype == 'void':
 	    break
 	if is_known_return_type(type) == 0:
@@ -469,6 +536,9 @@
 	test.write(");\n")
     test.write("        call_tests++;\n");
 
+    if extra_post_call.has_key(name):
+        test.write("        %s\n"% (extra_post_call[name]))
+
     # Free the arguments
     for arg in t_args:
         (nam, type, rtype, info) = arg;
@@ -479,11 +549,15 @@
     # Check the memory usage
     if no_mem == 0:
 	test.write("""        if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %%d blocks found in %s\\n",
+            printf("Leak of %%d blocks found in %s",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
-        }
 """ % (name));
+	for arg in t_args:
+	    (nam, type, rtype, info) = arg;
+	    test.write("""            printf(" %%d", n_%s);\n""" % (nam))
+	test.write("""            printf("\\n");\n""")
+	test.write("        }\n")
 
     for arg in t_args:
 	test.write("    }\n")
diff --git a/testapi.c b/testapi.c
index 5518548..75faa00 100644
--- a/testapi.c
+++ b/testapi.c
@@ -26,6 +26,8 @@
     int ret;
     int blocks, mem;
 
+    xmlInitParser();
+
     LIBXML_TEST_VERSION
 
     xmlSetStructuredErrorFunc(NULL, structured_errors);
@@ -304,8 +306,45 @@
 test_htmlAutoCloseTag(void) {
     int ret = 0;
 
+#ifdef LIBXML_HTML_ENABLED
+    int mem_base;
+    int ret_val;
+    htmlDocPtr doc; /* the HTML document */
+    int n_doc;
+    const xmlChar * name; /* The tag name */
+    int n_name;
+    htmlNodePtr elem; /* the HTML element */
+    int n_elem;
 
-    /* missing type support */
+    for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) {
+    for (n_name = 0;n_name < gen_nb_const_xmlChar_ptr;n_name++) {
+    for (n_elem = 0;n_elem < gen_nb_xmlNodePtr;n_elem++) {
+        mem_base = xmlMemBlocks();
+        doc = gen_xmlDocPtr(n_doc);
+        name = gen_const_xmlChar_ptr(n_name);
+        elem = gen_xmlNodePtr(n_elem);
+
+        ret_val = htmlAutoCloseTag(doc, name, elem);
+        desret_int(ret_val);
+        call_tests++;
+        des_xmlDocPtr(n_doc, doc);
+        des_const_xmlChar_ptr(n_name, name);
+        des_xmlNodePtr(n_elem, elem);
+        xmlResetLastError();
+        if (mem_base != xmlMemBlocks()) {
+            printf("Leak of %d blocks found in htmlAutoCloseTag",
+	           xmlMemBlocks() - mem_base);
+	    ret++;
+            printf(" %d", n_doc);
+            printf(" %d", n_name);
+            printf(" %d", n_elem);
+            printf("\n");
+        }
+    }
+    }
+    }
+#endif
+
     return(ret);
 }
 
@@ -334,18 +373,59 @@
 test_htmlCtxtReadDoc(void) {
     int ret = 0;
 
+#ifdef LIBXML_HTML_ENABLED
+    int mem_base;
+    htmlDocPtr ret_val;
+    htmlParserCtxtPtr ctxt; /* an HTML parser context */
+    int n_ctxt;
+    const xmlChar * cur; /* a pointer to a zero terminated string */
+    int n_cur;
+    const char * URL; /* the base URL to use for the document */
+    int n_URL;
+    const char * encoding; /* the document encoding, or NULL */
+    int n_encoding;
+    int options; /* a combination of htmlParserOption(s) */
+    int n_options;
 
-    /* missing type support */
-    return(ret);
-}
+    for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) {
+    for (n_cur = 0;n_cur < gen_nb_const_xmlChar_ptr;n_cur++) {
+    for (n_URL = 0;n_URL < gen_nb_filepath;n_URL++) {
+    for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) {
+    for (n_options = 0;n_options < gen_nb_int;n_options++) {
+        mem_base = xmlMemBlocks();
+        ctxt = gen_xmlParserCtxtPtr(n_ctxt);
+        cur = gen_const_xmlChar_ptr(n_cur);
+        URL = gen_filepath(n_URL);
+        encoding = gen_const_char_ptr(n_encoding);
+        options = gen_int(n_options);
 
+        ret_val = htmlCtxtReadDoc(ctxt, cur, URL, encoding, options);
+        desret_xmlDocPtr(ret_val);
+        call_tests++;
+        des_xmlParserCtxtPtr(n_ctxt, ctxt);
+        des_const_xmlChar_ptr(n_cur, cur);
+        des_filepath(n_URL, URL);
+        des_const_char_ptr(n_encoding, encoding);
+        des_int(n_options, options);
+        xmlResetLastError();
+        if (mem_base != xmlMemBlocks()) {
+            printf("Leak of %d blocks found in htmlCtxtReadDoc",
+	           xmlMemBlocks() - mem_base);
+	    ret++;
+            printf(" %d", n_ctxt);
+            printf(" %d", n_cur);
+            printf(" %d", n_URL);
+            printf(" %d", n_encoding);
+            printf(" %d", n_options);
+            printf("\n");
+        }
+    }
+    }
+    }
+    }
+    }
+#endif
 
-static int
-test_htmlCtxtReadFd(void) {
-    int ret = 0;
-
-
-    /* missing type support */
     return(ret);
 }
 
@@ -354,8 +434,52 @@
 test_htmlCtxtReadFile(void) {
     int ret = 0;
 
+#ifdef LIBXML_HTML_ENABLED
+    int mem_base;
+    htmlDocPtr ret_val;
+    htmlParserCtxtPtr ctxt; /* an HTML parser context */
+    int n_ctxt;
+    const char * filename; /* a file or URL */
+    int n_filename;
+    const char * encoding; /* the document encoding, or NULL */
+    int n_encoding;
+    int options; /* a combination of htmlParserOption(s) */
+    int n_options;
 
-    /* missing type support */
+    for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) {
+    for (n_filename = 0;n_filename < gen_nb_filepath;n_filename++) {
+    for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) {
+    for (n_options = 0;n_options < gen_nb_int;n_options++) {
+        mem_base = xmlMemBlocks();
+        ctxt = gen_xmlParserCtxtPtr(n_ctxt);
+        filename = gen_filepath(n_filename);
+        encoding = gen_const_char_ptr(n_encoding);
+        options = gen_int(n_options);
+
+        ret_val = htmlCtxtReadFile(ctxt, filename, encoding, options);
+        desret_xmlDocPtr(ret_val);
+        call_tests++;
+        des_xmlParserCtxtPtr(n_ctxt, ctxt);
+        des_filepath(n_filename, filename);
+        des_const_char_ptr(n_encoding, encoding);
+        des_int(n_options, options);
+        xmlResetLastError();
+        if (mem_base != xmlMemBlocks()) {
+            printf("Leak of %d blocks found in htmlCtxtReadFile",
+	           xmlMemBlocks() - mem_base);
+	    ret++;
+            printf(" %d", n_ctxt);
+            printf(" %d", n_filename);
+            printf(" %d", n_encoding);
+            printf(" %d", n_options);
+            printf("\n");
+        }
+    }
+    }
+    }
+    }
+#endif
+
     return(ret);
 }
 
@@ -374,8 +498,66 @@
 test_htmlCtxtReadMemory(void) {
     int ret = 0;
 
+#ifdef LIBXML_HTML_ENABLED
+    int mem_base;
+    htmlDocPtr ret_val;
+    htmlParserCtxtPtr ctxt; /* an HTML parser context */
+    int n_ctxt;
+    const char * buffer; /* a pointer to a char array */
+    int n_buffer;
+    int size; /* the size of the array */
+    int n_size;
+    const char * URL; /* the base URL to use for the document */
+    int n_URL;
+    const char * encoding; /* the document encoding, or NULL */
+    int n_encoding;
+    int options; /* a combination of htmlParserOption(s) */
+    int n_options;
 
-    /* missing type support */
+    for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) {
+    for (n_buffer = 0;n_buffer < gen_nb_const_char_ptr;n_buffer++) {
+    for (n_size = 0;n_size < gen_nb_int;n_size++) {
+    for (n_URL = 0;n_URL < gen_nb_filepath;n_URL++) {
+    for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) {
+    for (n_options = 0;n_options < gen_nb_int;n_options++) {
+        mem_base = xmlMemBlocks();
+        ctxt = gen_xmlParserCtxtPtr(n_ctxt);
+        buffer = gen_const_char_ptr(n_buffer);
+        size = gen_int(n_size);
+        URL = gen_filepath(n_URL);
+        encoding = gen_const_char_ptr(n_encoding);
+        options = gen_int(n_options);
+
+        ret_val = htmlCtxtReadMemory(ctxt, buffer, size, URL, encoding, options);
+        desret_xmlDocPtr(ret_val);
+        call_tests++;
+        des_xmlParserCtxtPtr(n_ctxt, ctxt);
+        des_const_char_ptr(n_buffer, buffer);
+        des_int(n_size, size);
+        des_filepath(n_URL, URL);
+        des_const_char_ptr(n_encoding, encoding);
+        des_int(n_options, options);
+        xmlResetLastError();
+        if (mem_base != xmlMemBlocks()) {
+            printf("Leak of %d blocks found in htmlCtxtReadMemory",
+	           xmlMemBlocks() - mem_base);
+	    ret++;
+            printf(" %d", n_ctxt);
+            printf(" %d", n_buffer);
+            printf(" %d", n_size);
+            printf(" %d", n_URL);
+            printf(" %d", n_encoding);
+            printf(" %d", n_options);
+            printf("\n");
+        }
+    }
+    }
+    }
+    }
+    }
+    }
+#endif
+
     return(ret);
 }
 
@@ -384,8 +566,29 @@
 test_htmlCtxtReset(void) {
     int ret = 0;
 
+#ifdef LIBXML_HTML_ENABLED
+    int mem_base;
+    htmlParserCtxtPtr ctxt; /* an HTML parser context */
+    int n_ctxt;
 
-    /* missing type support */
+    for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) {
+        mem_base = xmlMemBlocks();
+        ctxt = gen_xmlParserCtxtPtr(n_ctxt);
+
+        htmlCtxtReset(ctxt);
+        call_tests++;
+        des_xmlParserCtxtPtr(n_ctxt, ctxt);
+        xmlResetLastError();
+        if (mem_base != xmlMemBlocks()) {
+            printf("Leak of %d blocks found in htmlCtxtReset",
+	           xmlMemBlocks() - mem_base);
+	    ret++;
+            printf(" %d", n_ctxt);
+            printf("\n");
+        }
+    }
+#endif
+
     return(ret);
 }
 
@@ -394,8 +597,38 @@
 test_htmlCtxtUseOptions(void) {
     int ret = 0;
 
+#ifdef LIBXML_HTML_ENABLED
+    int mem_base;
+    int ret_val;
+    htmlParserCtxtPtr ctxt; /* an HTML parser context */
+    int n_ctxt;
+    int options; /* a combination of htmlParserOption(s) */
+    int n_options;
 
-    /* missing type support */
+    for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) {
+    for (n_options = 0;n_options < gen_nb_int;n_options++) {
+        mem_base = xmlMemBlocks();
+        ctxt = gen_xmlParserCtxtPtr(n_ctxt);
+        options = gen_int(n_options);
+
+        ret_val = htmlCtxtUseOptions(ctxt, options);
+        desret_int(ret_val);
+        call_tests++;
+        des_xmlParserCtxtPtr(n_ctxt, ctxt);
+        des_int(n_options, options);
+        xmlResetLastError();
+        if (mem_base != xmlMemBlocks()) {
+            printf("Leak of %d blocks found in htmlCtxtUseOptions",
+	           xmlMemBlocks() - mem_base);
+	    ret++;
+            printf(" %d", n_ctxt);
+            printf(" %d", n_options);
+            printf("\n");
+        }
+    }
+    }
+#endif
+
     return(ret);
 }
 
@@ -470,9 +703,11 @@
         des_int(n_val, val);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in htmlHandleOmittedElem\n",
+            printf("Leak of %d blocks found in htmlHandleOmittedElem",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_val);
+            printf("\n");
         }
     }
 #endif
@@ -485,8 +720,38 @@
 test_htmlIsAutoClosed(void) {
     int ret = 0;
 
+#ifdef LIBXML_HTML_ENABLED
+    int mem_base;
+    int ret_val;
+    htmlDocPtr doc; /* the HTML document */
+    int n_doc;
+    htmlNodePtr elem; /* the HTML element */
+    int n_elem;
 
-    /* missing type support */
+    for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) {
+    for (n_elem = 0;n_elem < gen_nb_xmlNodePtr;n_elem++) {
+        mem_base = xmlMemBlocks();
+        doc = gen_xmlDocPtr(n_doc);
+        elem = gen_xmlNodePtr(n_elem);
+
+        ret_val = htmlIsAutoClosed(doc, elem);
+        desret_int(ret_val);
+        call_tests++;
+        des_xmlDocPtr(n_doc, doc);
+        des_xmlNodePtr(n_elem, elem);
+        xmlResetLastError();
+        if (mem_base != xmlMemBlocks()) {
+            printf("Leak of %d blocks found in htmlIsAutoClosed",
+	           xmlMemBlocks() - mem_base);
+	    ret++;
+            printf(" %d", n_doc);
+            printf(" %d", n_elem);
+            printf("\n");
+        }
+    }
+    }
+#endif
+
     return(ret);
 }
 
@@ -511,9 +776,11 @@
         des_const_xmlChar_ptr(n_name, name);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in htmlIsScriptAttribute\n",
+            printf("Leak of %d blocks found in htmlIsScriptAttribute",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_name);
+            printf("\n");
         }
     }
 #endif
@@ -536,8 +803,31 @@
 test_htmlParseCharRef(void) {
     int ret = 0;
 
+#ifdef LIBXML_HTML_ENABLED
+    int mem_base;
+    int ret_val;
+    htmlParserCtxtPtr ctxt; /* an HTML parser context */
+    int n_ctxt;
 
-    /* missing type support */
+    for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) {
+        mem_base = xmlMemBlocks();
+        ctxt = gen_xmlParserCtxtPtr(n_ctxt);
+
+        ret_val = htmlParseCharRef(ctxt);
+        desret_int(ret_val);
+        call_tests++;
+        des_xmlParserCtxtPtr(n_ctxt, ctxt);
+        xmlResetLastError();
+        if (mem_base != xmlMemBlocks()) {
+            printf("Leak of %d blocks found in htmlParseCharRef",
+	           xmlMemBlocks() - mem_base);
+	    ret++;
+            printf(" %d", n_ctxt);
+            printf("\n");
+        }
+    }
+#endif
+
     return(ret);
 }
 
@@ -546,8 +836,54 @@
 test_htmlParseChunk(void) {
     int ret = 0;
 
+#ifdef LIBXML_HTML_ENABLED
+#ifdef LIBXML_PUSH_ENABLED
+    int mem_base;
+    int ret_val;
+    htmlParserCtxtPtr ctxt; /* an HTML parser context */
+    int n_ctxt;
+    const char * chunk; /* an char array */
+    int n_chunk;
+    int size; /* the size in byte of the chunk */
+    int n_size;
+    int terminate; /* last chunk indicator */
+    int n_terminate;
 
-    /* missing type support */
+    for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) {
+    for (n_chunk = 0;n_chunk < gen_nb_const_char_ptr;n_chunk++) {
+    for (n_size = 0;n_size < gen_nb_int;n_size++) {
+    for (n_terminate = 0;n_terminate < gen_nb_int;n_terminate++) {
+        mem_base = xmlMemBlocks();
+        ctxt = gen_xmlParserCtxtPtr(n_ctxt);
+        chunk = gen_const_char_ptr(n_chunk);
+        size = gen_int(n_size);
+        terminate = gen_int(n_terminate);
+
+        ret_val = htmlParseChunk(ctxt, chunk, size, terminate);
+        desret_int(ret_val);
+        call_tests++;
+        des_xmlParserCtxtPtr(n_ctxt, ctxt);
+        des_const_char_ptr(n_chunk, chunk);
+        des_int(n_size, size);
+        des_int(n_terminate, terminate);
+        xmlResetLastError();
+        if (mem_base != xmlMemBlocks()) {
+            printf("Leak of %d blocks found in htmlParseChunk",
+	           xmlMemBlocks() - mem_base);
+	    ret++;
+            printf(" %d", n_ctxt);
+            printf(" %d", n_chunk);
+            printf(" %d", n_size);
+            printf(" %d", n_terminate);
+            printf("\n");
+        }
+    }
+    }
+    }
+    }
+#endif
+#endif
+
     return(ret);
 }
 
@@ -566,8 +902,31 @@
 test_htmlParseDocument(void) {
     int ret = 0;
 
+#ifdef LIBXML_HTML_ENABLED
+    int mem_base;
+    int ret_val;
+    htmlParserCtxtPtr ctxt; /* an HTML parser context */
+    int n_ctxt;
 
-    /* missing type support */
+    for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) {
+        mem_base = xmlMemBlocks();
+        ctxt = gen_xmlParserCtxtPtr(n_ctxt);
+
+        ret_val = htmlParseDocument(ctxt);
+        desret_int(ret_val);
+        call_tests++;
+        des_xmlParserCtxtPtr(n_ctxt, ctxt);
+        xmlResetLastError();
+        if (mem_base != xmlMemBlocks()) {
+            printf("Leak of %d blocks found in htmlParseDocument",
+	           xmlMemBlocks() - mem_base);
+	    ret++;
+            printf(" %d", n_ctxt);
+            printf("\n");
+        }
+    }
+#endif
+
     return(ret);
 }
 
@@ -576,8 +935,29 @@
 test_htmlParseElement(void) {
     int ret = 0;
 
+#ifdef LIBXML_HTML_ENABLED
+    int mem_base;
+    htmlParserCtxtPtr ctxt; /* an HTML parser context */
+    int n_ctxt;
 
-    /* missing type support */
+    for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) {
+        mem_base = xmlMemBlocks();
+        ctxt = gen_xmlParserCtxtPtr(n_ctxt);
+
+        htmlParseElement(ctxt);
+        call_tests++;
+        des_xmlParserCtxtPtr(n_ctxt, ctxt);
+        xmlResetLastError();
+        if (mem_base != xmlMemBlocks()) {
+            printf("Leak of %d blocks found in htmlParseElement",
+	           xmlMemBlocks() - mem_base);
+	    ret++;
+            printf(" %d", n_ctxt);
+            printf("\n");
+        }
+    }
+#endif
+
     return(ret);
 }
 
@@ -596,8 +976,28 @@
 test_htmlParseFile(void) {
     int ret = 0;
 
+#ifdef LIBXML_HTML_ENABLED
+    htmlDocPtr ret_val;
+    const char * filename; /* the filename */
+    int n_filename;
+    const char * encoding; /* a free form C string describing the HTML document encoding, or NULL */
+    int n_encoding;
 
-    /* missing type support */
+    for (n_filename = 0;n_filename < gen_nb_filepath;n_filename++) {
+    for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) {
+        filename = gen_filepath(n_filename);
+        encoding = gen_const_char_ptr(n_encoding);
+
+        ret_val = htmlParseFile(filename, encoding);
+        desret_xmlDocPtr(ret_val);
+        call_tests++;
+        des_filepath(n_filename, filename);
+        des_const_char_ptr(n_encoding, encoding);
+        xmlResetLastError();
+    }
+    }
+#endif
+
     return(ret);
 }
 
@@ -606,18 +1006,52 @@
 test_htmlReadDoc(void) {
     int ret = 0;
 
+#ifdef LIBXML_HTML_ENABLED
+    int mem_base;
+    htmlDocPtr ret_val;
+    const xmlChar * cur; /* a pointer to a zero terminated string */
+    int n_cur;
+    const char * URL; /* the base URL to use for the document */
+    int n_URL;
+    const char * encoding; /* the document encoding, or NULL */
+    int n_encoding;
+    int options; /* a combination of htmlParserOption(s) */
+    int n_options;
 
-    /* missing type support */
-    return(ret);
-}
+    for (n_cur = 0;n_cur < gen_nb_const_xmlChar_ptr;n_cur++) {
+    for (n_URL = 0;n_URL < gen_nb_filepath;n_URL++) {
+    for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) {
+    for (n_options = 0;n_options < gen_nb_int;n_options++) {
+        mem_base = xmlMemBlocks();
+        cur = gen_const_xmlChar_ptr(n_cur);
+        URL = gen_filepath(n_URL);
+        encoding = gen_const_char_ptr(n_encoding);
+        options = gen_int(n_options);
 
+        ret_val = htmlReadDoc(cur, URL, encoding, options);
+        desret_xmlDocPtr(ret_val);
+        call_tests++;
+        des_const_xmlChar_ptr(n_cur, cur);
+        des_filepath(n_URL, URL);
+        des_const_char_ptr(n_encoding, encoding);
+        des_int(n_options, options);
+        xmlResetLastError();
+        if (mem_base != xmlMemBlocks()) {
+            printf("Leak of %d blocks found in htmlReadDoc",
+	           xmlMemBlocks() - mem_base);
+	    ret++;
+            printf(" %d", n_cur);
+            printf(" %d", n_URL);
+            printf(" %d", n_encoding);
+            printf(" %d", n_options);
+            printf("\n");
+        }
+    }
+    }
+    }
+    }
+#endif
 
-static int
-test_htmlReadFd(void) {
-    int ret = 0;
-
-
-    /* missing type support */
     return(ret);
 }
 
@@ -626,8 +1060,45 @@
 test_htmlReadFile(void) {
     int ret = 0;
 
+#ifdef LIBXML_HTML_ENABLED
+    int mem_base;
+    htmlDocPtr ret_val;
+    const char * filename; /* a file or URL */
+    int n_filename;
+    const char * encoding; /* the document encoding, or NULL */
+    int n_encoding;
+    int options; /* a combination of htmlParserOption(s) */
+    int n_options;
 
-    /* missing type support */
+    for (n_filename = 0;n_filename < gen_nb_filepath;n_filename++) {
+    for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) {
+    for (n_options = 0;n_options < gen_nb_int;n_options++) {
+        mem_base = xmlMemBlocks();
+        filename = gen_filepath(n_filename);
+        encoding = gen_const_char_ptr(n_encoding);
+        options = gen_int(n_options);
+
+        ret_val = htmlReadFile(filename, encoding, options);
+        desret_xmlDocPtr(ret_val);
+        call_tests++;
+        des_filepath(n_filename, filename);
+        des_const_char_ptr(n_encoding, encoding);
+        des_int(n_options, options);
+        xmlResetLastError();
+        if (mem_base != xmlMemBlocks()) {
+            printf("Leak of %d blocks found in htmlReadFile",
+	           xmlMemBlocks() - mem_base);
+	    ret++;
+            printf(" %d", n_filename);
+            printf(" %d", n_encoding);
+            printf(" %d", n_options);
+            printf("\n");
+        }
+    }
+    }
+    }
+#endif
+
     return(ret);
 }
 
@@ -646,8 +1117,59 @@
 test_htmlReadMemory(void) {
     int ret = 0;
 
+#ifdef LIBXML_HTML_ENABLED
+    int mem_base;
+    htmlDocPtr ret_val;
+    const char * buffer; /* a pointer to a char array */
+    int n_buffer;
+    int size; /* the size of the array */
+    int n_size;
+    const char * URL; /* the base URL to use for the document */
+    int n_URL;
+    const char * encoding; /* the document encoding, or NULL */
+    int n_encoding;
+    int options; /* a combination of htmlParserOption(s) */
+    int n_options;
 
-    /* missing type support */
+    for (n_buffer = 0;n_buffer < gen_nb_const_char_ptr;n_buffer++) {
+    for (n_size = 0;n_size < gen_nb_int;n_size++) {
+    for (n_URL = 0;n_URL < gen_nb_filepath;n_URL++) {
+    for (n_encoding = 0;n_encoding < gen_nb_const_char_ptr;n_encoding++) {
+    for (n_options = 0;n_options < gen_nb_int;n_options++) {
+        mem_base = xmlMemBlocks();
+        buffer = gen_const_char_ptr(n_buffer);
+        size = gen_int(n_size);
+        URL = gen_filepath(n_URL);
+        encoding = gen_const_char_ptr(n_encoding);
+        options = gen_int(n_options);
+
+        ret_val = htmlReadMemory(buffer, size, URL, encoding, options);
+        desret_xmlDocPtr(ret_val);
+        call_tests++;
+        des_const_char_ptr(n_buffer, buffer);
+        des_int(n_size, size);
+        des_filepath(n_URL, URL);
+        des_const_char_ptr(n_encoding, encoding);
+        des_int(n_options, options);
+        xmlResetLastError();
+        if (mem_base != xmlMemBlocks()) {
+            printf("Leak of %d blocks found in htmlReadMemory",
+	           xmlMemBlocks() - mem_base);
+	    ret++;
+            printf(" %d", n_buffer);
+            printf(" %d", n_size);
+            printf(" %d", n_URL);
+            printf(" %d", n_encoding);
+            printf(" %d", n_options);
+            printf("\n");
+        }
+    }
+    }
+    }
+    }
+    }
+#endif
+
     return(ret);
 }
 
@@ -692,7 +1214,6 @@
     ret += test_htmlCreateMemoryParserCtxt();
     ret += test_htmlCreatePushParserCtxt();
     ret += test_htmlCtxtReadDoc();
-    ret += test_htmlCtxtReadFd();
     ret += test_htmlCtxtReadFile();
     ret += test_htmlCtxtReadIO();
     ret += test_htmlCtxtReadMemory();
@@ -715,7 +1236,6 @@
     ret += test_htmlParseEntityRef();
     ret += test_htmlParseFile();
     ret += test_htmlReadDoc();
-    ret += test_htmlReadFd();
     ret += test_htmlReadFile();
     ret += test_htmlReadIO();
     ret += test_htmlReadMemory();
@@ -798,9 +1318,11 @@
         des_const_xmlChar_ptr(n_name, name);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in htmlIsBooleanAttr\n",
+            printf("Leak of %d blocks found in htmlIsBooleanAttr",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_name);
+            printf("\n");
         }
     }
 #endif
@@ -813,8 +1335,38 @@
 test_htmlNewDoc(void) {
     int ret = 0;
 
+#ifdef LIBXML_HTML_ENABLED
+    int mem_base;
+    htmlDocPtr ret_val;
+    const xmlChar * URI; /* URI for the dtd, or NULL */
+    int n_URI;
+    const xmlChar * ExternalID; /* the external ID of the DTD, or NULL */
+    int n_ExternalID;
 
-    /* missing type support */
+    for (n_URI = 0;n_URI < gen_nb_const_xmlChar_ptr;n_URI++) {
+    for (n_ExternalID = 0;n_ExternalID < gen_nb_const_xmlChar_ptr;n_ExternalID++) {
+        mem_base = xmlMemBlocks();
+        URI = gen_const_xmlChar_ptr(n_URI);
+        ExternalID = gen_const_xmlChar_ptr(n_ExternalID);
+
+        ret_val = htmlNewDoc(URI, ExternalID);
+        desret_xmlDocPtr(ret_val);
+        call_tests++;
+        des_const_xmlChar_ptr(n_URI, URI);
+        des_const_xmlChar_ptr(n_ExternalID, ExternalID);
+        xmlResetLastError();
+        if (mem_base != xmlMemBlocks()) {
+            printf("Leak of %d blocks found in htmlNewDoc",
+	           xmlMemBlocks() - mem_base);
+	    ret++;
+            printf(" %d", n_URI);
+            printf(" %d", n_ExternalID);
+            printf("\n");
+        }
+    }
+    }
+#endif
+
     return(ret);
 }
 
@@ -823,8 +1375,38 @@
 test_htmlNewDocNoDtD(void) {
     int ret = 0;
 
+#ifdef LIBXML_HTML_ENABLED
+    int mem_base;
+    htmlDocPtr ret_val;
+    const xmlChar * URI; /* URI for the dtd, or NULL */
+    int n_URI;
+    const xmlChar * ExternalID; /* the external ID of the DTD, or NULL */
+    int n_ExternalID;
 
-    /* missing type support */
+    for (n_URI = 0;n_URI < gen_nb_const_xmlChar_ptr;n_URI++) {
+    for (n_ExternalID = 0;n_ExternalID < gen_nb_const_xmlChar_ptr;n_ExternalID++) {
+        mem_base = xmlMemBlocks();
+        URI = gen_const_xmlChar_ptr(n_URI);
+        ExternalID = gen_const_xmlChar_ptr(n_ExternalID);
+
+        ret_val = htmlNewDocNoDtD(URI, ExternalID);
+        desret_xmlDocPtr(ret_val);
+        call_tests++;
+        des_const_xmlChar_ptr(n_URI, URI);
+        des_const_xmlChar_ptr(n_ExternalID, ExternalID);
+        xmlResetLastError();
+        if (mem_base != xmlMemBlocks()) {
+            printf("Leak of %d blocks found in htmlNewDocNoDtD",
+	           xmlMemBlocks() - mem_base);
+	    ret++;
+            printf(" %d", n_URI);
+            printf(" %d", n_ExternalID);
+            printf("\n");
+        }
+    }
+    }
+#endif
+
     return(ret);
 }
 
@@ -905,9 +1487,12 @@
         des_xmlDocPtr(n_cur, cur);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in htmlSaveFile\n",
+            printf("Leak of %d blocks found in htmlSaveFile",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_filename);
+            printf(" %d", n_cur);
+            printf("\n");
         }
     }
     }
@@ -949,9 +1534,13 @@
         des_const_char_ptr(n_encoding, encoding);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in htmlSaveFileEnc\n",
+            printf("Leak of %d blocks found in htmlSaveFileEnc",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_filename);
+            printf(" %d", n_cur);
+            printf(" %d", n_encoding);
+            printf("\n");
         }
     }
     }
@@ -999,9 +1588,14 @@
         des_int(n_format, format);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in htmlSaveFileFormat\n",
+            printf("Leak of %d blocks found in htmlSaveFileFormat",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_filename);
+            printf(" %d", n_cur);
+            printf(" %d", n_encoding);
+            printf(" %d", n_format);
+            printf("\n");
         }
     }
     }
@@ -1018,8 +1612,38 @@
 test_htmlSetMetaEncoding(void) {
     int ret = 0;
 
+#ifdef LIBXML_HTML_ENABLED
+    int mem_base;
+    int ret_val;
+    htmlDocPtr doc; /* the document */
+    int n_doc;
+    const xmlChar * encoding; /* the encoding string */
+    int n_encoding;
 
-    /* missing type support */
+    for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) {
+    for (n_encoding = 0;n_encoding < gen_nb_const_xmlChar_ptr;n_encoding++) {
+        mem_base = xmlMemBlocks();
+        doc = gen_xmlDocPtr(n_doc);
+        encoding = gen_const_xmlChar_ptr(n_encoding);
+
+        ret_val = htmlSetMetaEncoding(doc, encoding);
+        desret_int(ret_val);
+        call_tests++;
+        des_xmlDocPtr(n_doc, doc);
+        des_const_xmlChar_ptr(n_encoding, encoding);
+        xmlResetLastError();
+        if (mem_base != xmlMemBlocks()) {
+            printf("Leak of %d blocks found in htmlSetMetaEncoding",
+	           xmlMemBlocks() - mem_base);
+	    ret++;
+            printf(" %d", n_doc);
+            printf(" %d", n_encoding);
+            printf("\n");
+        }
+    }
+    }
+#endif
+
     return(ret);
 }
 
@@ -1205,9 +1829,13 @@
         des_const_xmlChar_ptr(n_replace, replace);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlCatalogAdd\n",
+            printf("Leak of %d blocks found in xmlCatalogAdd",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_type);
+            printf(" %d", n_orig);
+            printf(" %d", n_replace);
+            printf("\n");
         }
     }
     }
@@ -1233,18 +1861,11 @@
     int ret = 0;
 
 #ifdef LIBXML_CATALOG_ENABLED
-    int mem_base;
 
-        mem_base = xmlMemBlocks();
 
         xmlCatalogCleanup();
         call_tests++;
         xmlResetLastError();
-        if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlCatalogCleanup\n",
-	           xmlMemBlocks() - mem_base);
-	    ret++;
-        }
 #endif
 
     return(ret);
@@ -1423,9 +2044,11 @@
         des_int(n_level, level);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlCatalogSetDebug\n",
+            printf("Leak of %d blocks found in xmlCatalogSetDebug",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_level);
+            printf("\n");
         }
     }
 #endif
@@ -1477,9 +2100,10 @@
         call_tests++;
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlInitializeCatalog\n",
+            printf("Leak of %d blocks found in xmlInitializeCatalog",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf("\n");
         }
 #endif
 
@@ -1583,9 +2207,11 @@
         des_filepath(n_filename, filename);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlParseCatalogFile\n",
+            printf("Leak of %d blocks found in xmlParseCatalogFile",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_filename);
+            printf("\n");
         }
     }
 #endif
@@ -1948,9 +2574,10 @@
         call_tests++;
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlCleanupEncodingAliases\n",
+            printf("Leak of %d blocks found in xmlCleanupEncodingAliases",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf("\n");
         }
 
     return(ret);
@@ -1976,9 +2603,11 @@
         des_const_char_ptr(n_alias, alias);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlDelEncodingAlias\n",
+            printf("Leak of %d blocks found in xmlDelEncodingAlias",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_alias);
+            printf("\n");
         }
     }
 
@@ -2045,9 +2674,11 @@
         des_const_char_ptr(n_alias, alias);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlGetEncodingAlias\n",
+            printf("Leak of %d blocks found in xmlGetEncodingAlias",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_alias);
+            printf("\n");
         }
     }
 
@@ -2160,9 +2791,10 @@
         call_tests++;
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlCleanupPredefinedEntities\n",
+            printf("Leak of %d blocks found in xmlCleanupPredefinedEntities",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf("\n");
         }
 
     return(ret);
@@ -2291,9 +2923,10 @@
         call_tests++;
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlInitializePredefinedEntities\n",
+            printf("Leak of %d blocks found in xmlInitializePredefinedEntities",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf("\n");
         }
 
     return(ret);
@@ -2896,9 +3529,10 @@
         call_tests++;
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlNanoFTPCleanup\n",
+            printf("Leak of %d blocks found in xmlNanoFTPCleanup",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf("\n");
         }
 #endif
 
@@ -3019,9 +3653,10 @@
         call_tests++;
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlNanoFTPInit\n",
+            printf("Leak of %d blocks found in xmlNanoFTPInit",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf("\n");
         }
 #endif
 
@@ -3211,9 +3846,10 @@
         call_tests++;
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlNanoHTTPCleanup\n",
+            printf("Leak of %d blocks found in xmlNanoHTTPCleanup",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf("\n");
         }
 #endif
 
@@ -3274,9 +3910,10 @@
         call_tests++;
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlNanoHTTPInit\n",
+            printf("Leak of %d blocks found in xmlNanoHTTPInit",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf("\n");
         }
 #endif
 
@@ -3460,9 +4097,11 @@
         des_xmlParserCtxtPtr(n_ctxt, ctxt);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlClearParserCtxt\n",
+            printf("Leak of %d blocks found in xmlClearParserCtxt",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_ctxt);
+            printf("\n");
         }
     }
 
@@ -3539,9 +4178,15 @@
         des_int(n_options, options);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlCtxtReadDoc\n",
+            printf("Leak of %d blocks found in xmlCtxtReadDoc",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_ctxt);
+            printf(" %d", n_cur);
+            printf(" %d", n_URL);
+            printf(" %d", n_encoding);
+            printf(" %d", n_options);
+            printf("\n");
         }
     }
     }
@@ -3587,9 +4232,14 @@
         des_int(n_options, options);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlCtxtReadFile\n",
+            printf("Leak of %d blocks found in xmlCtxtReadFile",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_ctxt);
+            printf(" %d", n_filename);
+            printf(" %d", n_encoding);
+            printf(" %d", n_options);
+            printf("\n");
         }
     }
     }
@@ -3654,9 +4304,16 @@
         des_int(n_options, options);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlCtxtReadMemory\n",
+            printf("Leak of %d blocks found in xmlCtxtReadMemory",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_ctxt);
+            printf(" %d", n_buffer);
+            printf(" %d", n_size);
+            printf(" %d", n_URL);
+            printf(" %d", n_encoding);
+            printf(" %d", n_options);
+            printf("\n");
         }
     }
     }
@@ -3686,9 +4343,11 @@
         des_xmlParserCtxtPtr(n_ctxt, ctxt);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlCtxtReset\n",
+            printf("Leak of %d blocks found in xmlCtxtReset",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_ctxt);
+            printf("\n");
         }
     }
 
@@ -3735,9 +4394,15 @@
         des_const_char_ptr(n_encoding, encoding);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlCtxtResetPush\n",
+            printf("Leak of %d blocks found in xmlCtxtResetPush",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_ctxt);
+            printf(" %d", n_chunk);
+            printf(" %d", n_size);
+            printf(" %d", n_filename);
+            printf(" %d", n_encoding);
+            printf("\n");
         }
     }
     }
@@ -3773,9 +4438,12 @@
         des_int(n_options, options);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlCtxtUseOptions\n",
+            printf("Leak of %d blocks found in xmlCtxtUseOptions",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_ctxt);
+            printf(" %d", n_options);
+            printf("\n");
         }
     }
     }
@@ -3846,9 +4514,10 @@
         call_tests++;
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlInitParser\n",
+            printf("Leak of %d blocks found in xmlInitParser",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf("\n");
         }
 
     return(ret);
@@ -3874,9 +4543,11 @@
         des_xmlParserCtxtPtr(n_ctxt, ctxt);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlInitParserCtxt\n",
+            printf("Leak of %d blocks found in xmlInitParserCtxt",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_ctxt);
+            printf("\n");
         }
     }
 
@@ -3903,9 +4574,11 @@
         des_int(n_val, val);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlKeepBlanksDefault\n",
+            printf("Leak of %d blocks found in xmlKeepBlanksDefault",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_val);
+            printf("\n");
         }
     }
 
@@ -3932,9 +4605,11 @@
         des_int(n_val, val);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlLineNumbersDefault\n",
+            printf("Leak of %d blocks found in xmlLineNumbersDefault",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_val);
+            printf("\n");
         }
     }
 
@@ -4027,9 +4702,14 @@
         des_int(n_terminate, terminate);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlParseChunk\n",
+            printf("Leak of %d blocks found in xmlParseChunk",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_ctxt);
+            printf(" %d", n_chunk);
+            printf(" %d", n_size);
+            printf(" %d", n_terminate);
+            printf("\n");
         }
     }
     }
@@ -4090,9 +4770,11 @@
         des_xmlParserCtxtPtr(n_ctxt, ctxt);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlParseDocument\n",
+            printf("Leak of %d blocks found in xmlParseDocument",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_ctxt);
+            printf("\n");
         }
     }
 
@@ -4119,9 +4801,11 @@
         des_filepath(n_filename, filename);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlParseEntity\n",
+            printf("Leak of %d blocks found in xmlParseEntity",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_filename);
+            printf("\n");
         }
     }
 
@@ -4148,9 +4832,11 @@
         des_xmlParserCtxtPtr(n_ctxt, ctxt);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlParseExtParsedEnt\n",
+            printf("Leak of %d blocks found in xmlParseExtParsedEnt",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_ctxt);
+            printf("\n");
         }
     }
 
@@ -4187,9 +4873,11 @@
         des_filepath(n_filename, filename);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlParseFile\n",
+            printf("Leak of %d blocks found in xmlParseFile",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_filename);
+            printf("\n");
         }
     }
 
@@ -4231,9 +4919,12 @@
         des_int(n_size, size);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlParseMemory\n",
+            printf("Leak of %d blocks found in xmlParseMemory",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_buffer);
+            printf(" %d", n_size);
+            printf("\n");
         }
     }
     }
@@ -4311,9 +5002,11 @@
         des_int(n_val, val);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlPedanticParserDefault\n",
+            printf("Leak of %d blocks found in xmlPedanticParserDefault",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_val);
+            printf("\n");
         }
     }
 
@@ -4355,9 +5048,14 @@
         des_int(n_options, options);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlReadDoc\n",
+            printf("Leak of %d blocks found in xmlReadDoc",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_cur);
+            printf(" %d", n_URL);
+            printf(" %d", n_encoding);
+            printf(" %d", n_options);
+            printf("\n");
         }
     }
     }
@@ -4397,9 +5095,13 @@
         des_int(n_options, options);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlReadFile\n",
+            printf("Leak of %d blocks found in xmlReadFile",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_filename);
+            printf(" %d", n_encoding);
+            printf(" %d", n_options);
+            printf("\n");
         }
     }
     }
@@ -4458,9 +5160,15 @@
         des_int(n_options, options);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlReadMemory\n",
+            printf("Leak of %d blocks found in xmlReadMemory",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_buffer);
+            printf(" %d", n_size);
+            printf(" %d", n_URL);
+            printf(" %d", n_encoding);
+            printf(" %d", n_options);
+            printf("\n");
         }
     }
     }
@@ -4501,9 +5209,11 @@
         des_filepath(n_filename, filename);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlRecoverFile\n",
+            printf("Leak of %d blocks found in xmlRecoverFile",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_filename);
+            printf("\n");
         }
     }
 
@@ -4535,9 +5245,12 @@
         des_int(n_size, size);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlRecoverMemory\n",
+            printf("Leak of %d blocks found in xmlRecoverMemory",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_buffer);
+            printf(" %d", n_size);
+            printf("\n");
         }
     }
     }
@@ -4683,9 +5396,13 @@
         des_filepath(n_filename, filename);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlSetupParserForBuffer\n",
+            printf("Leak of %d blocks found in xmlSetupParserForBuffer",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_ctxt);
+            printf(" %d", n_buffer);
+            printf(" %d", n_filename);
+            printf("\n");
         }
     }
     }
@@ -4712,9 +5429,11 @@
         des_xmlParserCtxtPtr(n_ctxt, ctxt);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlStopParser\n",
+            printf("Leak of %d blocks found in xmlStopParser",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_ctxt);
+            printf("\n");
         }
     }
 
@@ -4741,9 +5460,11 @@
         des_int(n_val, val);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlSubstituteEntitiesDefault\n",
+            printf("Leak of %d blocks found in xmlSubstituteEntitiesDefault",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_val);
+            printf("\n");
         }
     }
 
@@ -4871,9 +5592,10 @@
         call_tests++;
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlRelaxNGCleanupTypes\n",
+            printf("Leak of %d blocks found in xmlRelaxNGCleanupTypes",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf("\n");
         }
 #endif
 
@@ -5100,22 +5822,26 @@
     xmlNodePtr cur; /* the child node */
     int n_cur;
 
-    for (n_parent = 0;n_parent < gen_nb_xmlNodePtr_in;n_parent++) {
+    for (n_parent = 0;n_parent < gen_nb_xmlNodePtr;n_parent++) {
     for (n_cur = 0;n_cur < gen_nb_xmlNodePtr_in;n_cur++) {
         mem_base = xmlMemBlocks();
-        parent = gen_xmlNodePtr_in(n_parent);
+        parent = gen_xmlNodePtr(n_parent);
         cur = gen_xmlNodePtr_in(n_cur);
 
         ret_val = xmlAddChild(parent, cur);
         desret_xmlNodePtr(ret_val);
         call_tests++;
-        des_xmlNodePtr_in(n_parent, parent);
+        if (ret_val == NULL) { xmlFreeNode(cur) ; cur = NULL ; }
+        des_xmlNodePtr(n_parent, parent);
         des_xmlNodePtr_in(n_cur, cur);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlAddChild\n",
+            printf("Leak of %d blocks found in xmlAddChild",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_parent);
+            printf(" %d", n_cur);
+            printf("\n");
         }
     }
     }
@@ -5135,22 +5861,26 @@
     xmlNodePtr cur; /* the first node in the list */
     int n_cur;
 
-    for (n_parent = 0;n_parent < gen_nb_xmlNodePtr_in;n_parent++) {
+    for (n_parent = 0;n_parent < gen_nb_xmlNodePtr;n_parent++) {
     for (n_cur = 0;n_cur < gen_nb_xmlNodePtr_in;n_cur++) {
         mem_base = xmlMemBlocks();
-        parent = gen_xmlNodePtr_in(n_parent);
+        parent = gen_xmlNodePtr(n_parent);
         cur = gen_xmlNodePtr_in(n_cur);
 
         ret_val = xmlAddChildList(parent, cur);
         desret_xmlNodePtr(ret_val);
         call_tests++;
-        des_xmlNodePtr_in(n_parent, parent);
+        if (ret_val == NULL) { xmlFreeNodeList(cur) ; cur = NULL ; }
+        des_xmlNodePtr(n_parent, parent);
         des_xmlNodePtr_in(n_cur, cur);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlAddChildList\n",
+            printf("Leak of %d blocks found in xmlAddChildList",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_parent);
+            printf(" %d", n_cur);
+            printf("\n");
         }
     }
     }
@@ -5171,21 +5901,25 @@
     int n_elem;
 
     for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) {
-    for (n_elem = 0;n_elem < gen_nb_xmlNodePtr;n_elem++) {
+    for (n_elem = 0;n_elem < gen_nb_xmlNodePtr_in;n_elem++) {
         mem_base = xmlMemBlocks();
         cur = gen_xmlNodePtr(n_cur);
-        elem = gen_xmlNodePtr(n_elem);
+        elem = gen_xmlNodePtr_in(n_elem);
 
         ret_val = xmlAddNextSibling(cur, elem);
         desret_xmlNodePtr(ret_val);
         call_tests++;
+        if (ret_val == NULL) { xmlFreeNode(elem) ; elem = NULL ; }
         des_xmlNodePtr(n_cur, cur);
-        des_xmlNodePtr(n_elem, elem);
+        des_xmlNodePtr_in(n_elem, elem);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlAddNextSibling\n",
+            printf("Leak of %d blocks found in xmlAddNextSibling",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_cur);
+            printf(" %d", n_elem);
+            printf("\n");
         }
     }
     }
@@ -5207,21 +5941,25 @@
     int n_elem;
 
     for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) {
-    for (n_elem = 0;n_elem < gen_nb_xmlNodePtr;n_elem++) {
+    for (n_elem = 0;n_elem < gen_nb_xmlNodePtr_in;n_elem++) {
         mem_base = xmlMemBlocks();
         cur = gen_xmlNodePtr(n_cur);
-        elem = gen_xmlNodePtr(n_elem);
+        elem = gen_xmlNodePtr_in(n_elem);
 
         ret_val = xmlAddPrevSibling(cur, elem);
         desret_xmlNodePtr(ret_val);
         call_tests++;
+        if (ret_val == NULL) { xmlFreeNode(elem) ; elem = NULL ; }
         des_xmlNodePtr(n_cur, cur);
-        des_xmlNodePtr(n_elem, elem);
+        des_xmlNodePtr_in(n_elem, elem);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlAddPrevSibling\n",
+            printf("Leak of %d blocks found in xmlAddPrevSibling",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_cur);
+            printf(" %d", n_elem);
+            printf("\n");
         }
     }
     }
@@ -5243,21 +5981,25 @@
     int n_elem;
 
     for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) {
-    for (n_elem = 0;n_elem < gen_nb_xmlNodePtr;n_elem++) {
+    for (n_elem = 0;n_elem < gen_nb_xmlNodePtr_in;n_elem++) {
         mem_base = xmlMemBlocks();
         cur = gen_xmlNodePtr(n_cur);
-        elem = gen_xmlNodePtr(n_elem);
+        elem = gen_xmlNodePtr_in(n_elem);
 
         ret_val = xmlAddSibling(cur, elem);
         desret_xmlNodePtr(ret_val);
         call_tests++;
+        if (ret_val == NULL) { xmlFreeNode(elem) ; elem = NULL ; }
         des_xmlNodePtr(n_cur, cur);
-        des_xmlNodePtr(n_elem, elem);
+        des_xmlNodePtr_in(n_elem, elem);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlAddSibling\n",
+            printf("Leak of %d blocks found in xmlAddSibling",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_cur);
+            printf(" %d", n_elem);
+            printf("\n");
         }
     }
     }
@@ -5491,9 +6233,12 @@
         des_int(n_recursive, recursive);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlCopyDoc\n",
+            printf("Leak of %d blocks found in xmlCopyDoc",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_doc);
+            printf(" %d", n_recursive);
+            printf("\n");
         }
     }
     }
@@ -5682,9 +6427,11 @@
         des_xmlDocPtr(n_doc, doc);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlDocGetRootElement\n",
+            printf("Leak of %d blocks found in xmlDocGetRootElement",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_doc);
+            printf("\n");
         }
     }
 
@@ -5705,21 +6452,25 @@
     int n_root;
 
     for (n_doc = 0;n_doc < gen_nb_xmlDocPtr;n_doc++) {
-    for (n_root = 0;n_root < gen_nb_xmlNodePtr;n_root++) {
+    for (n_root = 0;n_root < gen_nb_xmlNodePtr_in;n_root++) {
         mem_base = xmlMemBlocks();
         doc = gen_xmlDocPtr(n_doc);
-        root = gen_xmlNodePtr(n_root);
+        root = gen_xmlNodePtr_in(n_root);
 
         ret_val = xmlDocSetRootElement(doc, root);
         desret_xmlNodePtr(ret_val);
         call_tests++;
+        if (doc == NULL) { xmlFreeNode(root) ; root = NULL ; }
         des_xmlDocPtr(n_doc, doc);
-        des_xmlNodePtr(n_root, root);
+        des_xmlNodePtr_in(n_root, root);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlDocSetRootElement\n",
+            printf("Leak of %d blocks found in xmlDocSetRootElement",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_doc);
+            printf(" %d", n_root);
+            printf("\n");
         }
     }
     }
@@ -5763,9 +6514,10 @@
         call_tests++;
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlGetCompressMode\n",
+            printf("Leak of %d blocks found in xmlGetCompressMode",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf("\n");
         }
 
     return(ret);
@@ -5791,9 +6543,11 @@
         des_xmlDocPtr(n_doc, doc);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlGetDocCompressMode\n",
+            printf("Leak of %d blocks found in xmlGetDocCompressMode",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_doc);
+            printf("\n");
         }
     }
 
@@ -5830,9 +6584,11 @@
         des_xmlNodePtr(n_parent, parent);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlGetLastChild\n",
+            printf("Leak of %d blocks found in xmlGetLastChild",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_parent);
+            printf("\n");
         }
     }
 
@@ -5939,9 +6695,11 @@
         des_xmlNodePtr(n_node, node);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlIsBlankNode\n",
+            printf("Leak of %d blocks found in xmlIsBlankNode",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_node);
+            printf("\n");
         }
     }
 
@@ -5973,9 +6731,12 @@
         des_const_xmlChar_ptr(n_publicID, publicID);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlIsXHTML\n",
+            printf("Leak of %d blocks found in xmlIsXHTML",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_systemID);
+            printf(" %d", n_publicID);
+            printf("\n");
         }
     }
     }
@@ -6013,9 +6774,13 @@
         des_int(n_len, len);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlNewCDataBlock\n",
+            printf("Leak of %d blocks found in xmlNewCDataBlock",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_doc);
+            printf(" %d", n_content);
+            printf(" %d", n_len);
+            printf("\n");
         }
     }
     }
@@ -6049,9 +6814,12 @@
         des_const_xmlChar_ptr(n_name, name);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlNewCharRef\n",
+            printf("Leak of %d blocks found in xmlNewCharRef",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_doc);
+            printf(" %d", n_name);
+            printf("\n");
         }
     }
     }
@@ -6089,9 +6857,11 @@
         des_const_xmlChar_ptr(n_content, content);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlNewComment\n",
+            printf("Leak of %d blocks found in xmlNewComment",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_content);
+            printf("\n");
         }
     }
 
@@ -6118,9 +6888,11 @@
         des_const_xmlChar_ptr(n_version, version);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlNewDoc\n",
+            printf("Leak of %d blocks found in xmlNewDoc",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_version);
+            printf("\n");
         }
     }
 
@@ -6152,9 +6924,12 @@
         des_const_xmlChar_ptr(n_content, content);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlNewDocComment\n",
+            printf("Leak of %d blocks found in xmlNewDocComment",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_doc);
+            printf(" %d", n_content);
+            printf("\n");
         }
     }
     }
@@ -6183,9 +6958,11 @@
         des_xmlDocPtr(n_doc, doc);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlNewDocFragment\n",
+            printf("Leak of %d blocks found in xmlNewDocFragment",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_doc);
+            printf("\n");
         }
     }
 #endif
@@ -6243,9 +7020,13 @@
         des_const_xmlChar_ptr(n_content, content);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlNewDocPI\n",
+            printf("Leak of %d blocks found in xmlNewDocPI",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_doc);
+            printf(" %d", n_name);
+            printf(" %d", n_content);
+            printf("\n");
         }
     }
     }
@@ -6299,9 +7080,12 @@
         des_const_xmlChar_ptr(n_content, content);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlNewDocText\n",
+            printf("Leak of %d blocks found in xmlNewDocText",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_doc);
+            printf(" %d", n_content);
+            printf("\n");
         }
     }
     }
@@ -6339,9 +7123,13 @@
         des_int(n_len, len);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlNewDocTextLen\n",
+            printf("Leak of %d blocks found in xmlNewDocTextLen",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_doc);
+            printf(" %d", n_content);
+            printf(" %d", n_len);
+            printf("\n");
         }
     }
     }
@@ -6445,9 +7233,12 @@
         des_const_xmlChar_ptr(n_content, content);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlNewPI\n",
+            printf("Leak of %d blocks found in xmlNewPI",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_name);
+            printf(" %d", n_content);
+            printf("\n");
         }
     }
     }
@@ -6490,9 +7281,12 @@
         des_const_xmlChar_ptr(n_name, name);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlNewReference\n",
+            printf("Leak of %d blocks found in xmlNewReference",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_doc);
+            printf(" %d", n_name);
+            printf("\n");
         }
     }
     }
@@ -6520,9 +7314,11 @@
         des_const_xmlChar_ptr(n_content, content);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlNewText\n",
+            printf("Leak of %d blocks found in xmlNewText",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_content);
+            printf("\n");
         }
     }
 
@@ -6564,9 +7360,12 @@
         des_int(n_len, len);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlNewTextLen\n",
+            printf("Leak of %d blocks found in xmlNewTextLen",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_content);
+            printf(" %d", n_len);
+            printf("\n");
         }
     }
     }
@@ -6597,9 +7396,12 @@
         des_const_xmlChar_ptr(n_content, content);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlNodeAddContent\n",
+            printf("Leak of %d blocks found in xmlNodeAddContent",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_cur);
+            printf(" %d", n_content);
+            printf("\n");
         }
     }
     }
@@ -6635,9 +7437,13 @@
         des_int(n_len, len);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlNodeAddContentLen\n",
+            printf("Leak of %d blocks found in xmlNodeAddContentLen",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_cur);
+            printf(" %d", n_content);
+            printf(" %d", n_len);
+            printf("\n");
         }
     }
     }
@@ -6726,9 +7532,11 @@
         des_xmlNodePtr(n_cur, cur);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlNodeGetSpacePreserve\n",
+            printf("Leak of %d blocks found in xmlNodeGetSpacePreserve",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_cur);
+            printf("\n");
         }
     }
 
@@ -6755,9 +7563,11 @@
         des_xmlNodePtr(n_node, node);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlNodeIsText\n",
+            printf("Leak of %d blocks found in xmlNodeIsText",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_node);
+            printf("\n");
         }
     }
 
@@ -6808,9 +7618,12 @@
         des_const_xmlChar_ptr(n_uri, uri);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlNodeSetBase\n",
+            printf("Leak of %d blocks found in xmlNodeSetBase",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_cur);
+            printf(" %d", n_uri);
+            printf("\n");
         }
     }
     }
@@ -6842,9 +7655,12 @@
         des_const_xmlChar_ptr(n_content, content);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlNodeSetContent\n",
+            printf("Leak of %d blocks found in xmlNodeSetContent",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_cur);
+            printf(" %d", n_content);
+            printf("\n");
         }
     }
     }
@@ -6881,9 +7697,13 @@
         des_int(n_len, len);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlNodeSetContentLen\n",
+            printf("Leak of %d blocks found in xmlNodeSetContentLen",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_cur);
+            printf(" %d", n_content);
+            printf(" %d", n_len);
+            printf("\n");
         }
     }
     }
@@ -6917,9 +7737,12 @@
         des_const_xmlChar_ptr(n_lang, lang);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlNodeSetLang\n",
+            printf("Leak of %d blocks found in xmlNodeSetLang",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_cur);
+            printf(" %d", n_lang);
+            printf("\n");
         }
     }
     }
@@ -6952,9 +7775,12 @@
         des_const_xmlChar_ptr(n_name, name);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlNodeSetName\n",
+            printf("Leak of %d blocks found in xmlNodeSetName",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_cur);
+            printf(" %d", n_name);
+            printf("\n");
         }
     }
     }
@@ -6987,9 +7813,12 @@
         des_int(n_val, val);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlNodeSetSpacePreserve\n",
+            printf("Leak of %d blocks found in xmlNodeSetSpacePreserve",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_cur);
+            printf(" %d", n_val);
+            printf("\n");
         }
     }
     }
@@ -7023,9 +7852,12 @@
         des_xmlNodePtr(n_tree, tree);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlReconciliateNs\n",
+            printf("Leak of %d blocks found in xmlReconciliateNs",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_doc);
+            printf(" %d", n_tree);
+            printf("\n");
         }
     }
     }
@@ -7057,21 +7889,26 @@
     int n_cur;
 
     for (n_old = 0;n_old < gen_nb_xmlNodePtr;n_old++) {
-    for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) {
+    for (n_cur = 0;n_cur < gen_nb_xmlNodePtr_in;n_cur++) {
         mem_base = xmlMemBlocks();
         old = gen_xmlNodePtr(n_old);
-        cur = gen_xmlNodePtr(n_cur);
+        cur = gen_xmlNodePtr_in(n_cur);
 
         ret_val = xmlReplaceNode(old, cur);
         desret_xmlNodePtr(ret_val);
         call_tests++;
+        if ((old == NULL) || (old->parent == NULL)) {
+              xmlFreeNode(cur) ; cur = NULL ; }
         des_xmlNodePtr(n_old, old);
-        des_xmlNodePtr(n_cur, cur);
+        des_xmlNodePtr_in(n_cur, cur);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlReplaceNode\n",
+            printf("Leak of %d blocks found in xmlReplaceNode",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_old);
+            printf(" %d", n_cur);
+            printf("\n");
         }
     }
     }
@@ -7106,9 +7943,12 @@
         des_xmlDocPtr(n_cur, cur);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlSaveFile\n",
+            printf("Leak of %d blocks found in xmlSaveFile",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_filename);
+            printf(" %d", n_cur);
+            printf("\n");
         }
     }
     }
@@ -7148,9 +7988,13 @@
         des_const_char_ptr(n_encoding, encoding);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlSaveFileEnc\n",
+            printf("Leak of %d blocks found in xmlSaveFileEnc",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_filename);
+            printf(" %d", n_cur);
+            printf(" %d", n_encoding);
+            printf("\n");
         }
     }
     }
@@ -7201,9 +8045,13 @@
         des_int(n_format, format);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlSaveFormatFile\n",
+            printf("Leak of %d blocks found in xmlSaveFormatFile",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_filename);
+            printf(" %d", n_cur);
+            printf(" %d", n_format);
+            printf("\n");
         }
     }
     }
@@ -7249,9 +8097,14 @@
         des_int(n_format, format);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlSaveFormatFileEnc\n",
+            printf("Leak of %d blocks found in xmlSaveFormatFileEnc",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_filename);
+            printf(" %d", n_cur);
+            printf(" %d", n_encoding);
+            printf(" %d", n_format);
+            printf("\n");
         }
     }
     }
@@ -7320,9 +8173,11 @@
         des_int(n_mode, mode);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlSetCompressMode\n",
+            printf("Leak of %d blocks found in xmlSetCompressMode",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_mode);
+            printf("\n");
         }
     }
 
@@ -7352,9 +8207,12 @@
         des_int(n_mode, mode);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlSetDocCompressMode\n",
+            printf("Leak of %d blocks found in xmlSetDocCompressMode",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_doc);
+            printf(" %d", n_mode);
+            printf("\n");
         }
     }
     }
@@ -7385,9 +8243,12 @@
         des_xmlDocPtr(n_doc, doc);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlSetListDoc\n",
+            printf("Leak of %d blocks found in xmlSetListDoc",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_list);
+            printf(" %d", n_doc);
+            printf("\n");
         }
     }
     }
@@ -7448,9 +8309,12 @@
         des_xmlDocPtr(n_doc, doc);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlSetTreeDoc\n",
+            printf("Leak of %d blocks found in xmlSetTreeDoc",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_tree);
+            printf(" %d", n_doc);
+            printf("\n");
         }
     }
     }
@@ -7503,9 +8367,12 @@
         des_const_xmlChar_ptr(n_value, value);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlStringGetNodeList\n",
+            printf("Leak of %d blocks found in xmlStringGetNodeList",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_doc);
+            printf(" %d", n_value);
+            printf("\n");
         }
     }
     }
@@ -7543,9 +8410,13 @@
         des_int(n_len, len);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlStringLenGetNodeList\n",
+            printf("Leak of %d blocks found in xmlStringLenGetNodeList",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_doc);
+            printf(" %d", n_value);
+            printf(" %d", n_len);
+            printf("\n");
         }
     }
     }
@@ -7584,9 +8455,13 @@
         des_int(n_len, len);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlTextConcat\n",
+            printf("Leak of %d blocks found in xmlTextConcat",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_node);
+            printf(" %d", n_content);
+            printf(" %d", n_len);
+            printf("\n");
         }
     }
     }
@@ -7607,22 +8482,27 @@
     xmlNodePtr second; /* the second text node being merged */
     int n_second;
 
-    for (n_first = 0;n_first < gen_nb_xmlNodePtr;n_first++) {
-    for (n_second = 0;n_second < gen_nb_xmlNodePtr;n_second++) {
+    for (n_first = 0;n_first < gen_nb_xmlNodePtr_in;n_first++) {
+    for (n_second = 0;n_second < gen_nb_xmlNodePtr_in;n_second++) {
         mem_base = xmlMemBlocks();
-        first = gen_xmlNodePtr(n_first);
-        second = gen_xmlNodePtr(n_second);
+        first = gen_xmlNodePtr_in(n_first);
+        second = gen_xmlNodePtr_in(n_second);
 
         ret_val = xmlTextMerge(first, second);
         desret_xmlNodePtr(ret_val);
         call_tests++;
-        des_xmlNodePtr(n_first, first);
-        des_xmlNodePtr(n_second, second);
+        if ((first != NULL) && (first->type != XML_TEXT_NODE)) {
+              xmlFreeNode(second) ; second = NULL ; }
+        des_xmlNodePtr_in(n_first, first);
+        des_xmlNodePtr_in(n_second, second);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlTextMerge\n",
+            printf("Leak of %d blocks found in xmlTextMerge",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_first);
+            printf(" %d", n_second);
+            printf("\n");
         }
     }
     }
@@ -7648,9 +8528,11 @@
         des_xmlNodePtr(n_cur, cur);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlUnlinkNode\n",
+            printf("Leak of %d blocks found in xmlUnlinkNode",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_cur);
+            printf("\n");
         }
     }
 
@@ -7693,9 +8575,12 @@
         des_const_xmlChar_ptr(n_name, name);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlUnsetProp\n",
+            printf("Leak of %d blocks found in xmlUnsetProp",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_node);
+            printf(" %d", n_name);
+            printf("\n");
         }
     }
     }
@@ -7729,9 +8614,12 @@
         des_int(n_space, space);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlValidateNCName\n",
+            printf("Leak of %d blocks found in xmlValidateNCName",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_value);
+            printf(" %d", n_space);
+            printf("\n");
         }
     }
     }
@@ -7764,9 +8652,12 @@
         des_int(n_space, space);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlValidateNMToken\n",
+            printf("Leak of %d blocks found in xmlValidateNMToken",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_value);
+            printf(" %d", n_space);
+            printf("\n");
         }
     }
     }
@@ -7799,9 +8690,12 @@
         des_int(n_space, space);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlValidateName\n",
+            printf("Leak of %d blocks found in xmlValidateName",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_value);
+            printf(" %d", n_space);
+            printf("\n");
         }
     }
     }
@@ -7834,9 +8728,12 @@
         des_int(n_space, space);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlValidateQName\n",
+            printf("Leak of %d blocks found in xmlValidateQName",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_value);
+            printf(" %d", n_space);
+            printf("\n");
         }
     }
     }
@@ -8408,9 +9305,12 @@
         des_const_xmlChar_ptr(n_name, name);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlIsMixedElement\n",
+            printf("Leak of %d blocks found in xmlIsMixedElement",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_doc);
+            printf(" %d", n_name);
+            printf("\n");
         }
     }
     }
@@ -8639,9 +9539,11 @@
         des_const_xmlChar_ptr(n_value, value);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlValidateNameValue\n",
+            printf("Leak of %d blocks found in xmlValidateNameValue",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_value);
+            printf("\n");
         }
     }
 #endif
@@ -8670,9 +9572,11 @@
         des_const_xmlChar_ptr(n_value, value);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlValidateNamesValue\n",
+            printf("Leak of %d blocks found in xmlValidateNamesValue",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_value);
+            printf("\n");
         }
     }
 #endif
@@ -8701,9 +9605,11 @@
         des_const_xmlChar_ptr(n_value, value);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlValidateNmtokenValue\n",
+            printf("Leak of %d blocks found in xmlValidateNmtokenValue",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_value);
+            printf("\n");
         }
     }
 #endif
@@ -8732,9 +9638,11 @@
         des_const_xmlChar_ptr(n_value, value);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlValidateNmtokensValue\n",
+            printf("Leak of %d blocks found in xmlValidateNmtokensValue",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_value);
+            printf("\n");
         }
     }
 #endif
@@ -8932,9 +9840,11 @@
         des_xmlDocPtr(n_doc, doc);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlXIncludeProcess\n",
+            printf("Leak of %d blocks found in xmlXIncludeProcess",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_doc);
+            printf("\n");
         }
     }
 #endif
@@ -8968,9 +9878,12 @@
         des_int(n_flags, flags);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlXIncludeProcessFlags\n",
+            printf("Leak of %d blocks found in xmlXIncludeProcessFlags",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_doc);
+            printf(" %d", n_flags);
+            printf("\n");
         }
     }
     }
@@ -9010,9 +9923,11 @@
         des_xmlNodePtr(n_tree, tree);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlXIncludeProcessTree\n",
+            printf("Leak of %d blocks found in xmlXIncludeProcessTree",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_tree);
+            printf("\n");
         }
     }
 #endif
@@ -9046,9 +9961,12 @@
         des_int(n_flags, flags);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlXIncludeProcessTreeFlags\n",
+            printf("Leak of %d blocks found in xmlXIncludeProcessTreeFlags",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_tree);
+            printf(" %d", n_flags);
+            printf("\n");
         }
     }
     }
@@ -9124,9 +10042,11 @@
         des_const_char_ptr(n_path, path);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlCheckFilename\n",
+            printf("Leak of %d blocks found in xmlCheckFilename",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_path);
+            printf("\n");
         }
     }
 
@@ -9156,9 +10076,10 @@
         call_tests++;
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlCleanupInputCallbacks\n",
+            printf("Leak of %d blocks found in xmlCleanupInputCallbacks",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf("\n");
         }
 
     return(ret);
@@ -9178,9 +10099,10 @@
         call_tests++;
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlCleanupOutputCallbacks\n",
+            printf("Leak of %d blocks found in xmlCleanupOutputCallbacks",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf("\n");
         }
 #endif
 
@@ -9217,9 +10139,11 @@
         des_filepath(n_filename, filename);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlFileMatch\n",
+            printf("Leak of %d blocks found in xmlFileMatch",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_filename);
+            printf("\n");
         }
     }
 
@@ -9277,9 +10201,11 @@
         des_filepath(n_filename, filename);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlIOFTPMatch\n",
+            printf("Leak of %d blocks found in xmlIOFTPMatch",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_filename);
+            printf("\n");
         }
     }
 #endif
@@ -9338,9 +10264,11 @@
         des_filepath(n_filename, filename);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlIOHTTPMatch\n",
+            printf("Leak of %d blocks found in xmlIOHTTPMatch",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_filename);
+            printf("\n");
         }
     }
 #endif
@@ -9603,9 +10531,10 @@
         call_tests++;
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlPopInputCallbacks\n",
+            printf("Leak of %d blocks found in xmlPopInputCallbacks",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf("\n");
         }
 
     return(ret);
@@ -9624,9 +10553,10 @@
         call_tests++;
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlRegisterDefaultInputCallbacks\n",
+            printf("Leak of %d blocks found in xmlRegisterDefaultInputCallbacks",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf("\n");
         }
 
     return(ret);
@@ -9646,9 +10576,10 @@
         call_tests++;
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlRegisterDefaultOutputCallbacks\n",
+            printf("Leak of %d blocks found in xmlRegisterDefaultOutputCallbacks",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf("\n");
         }
 #endif
 
@@ -9669,9 +10600,10 @@
         call_tests++;
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlRegisterHTTPPostCallbacks\n",
+            printf("Leak of %d blocks found in xmlRegisterHTTPPostCallbacks",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf("\n");
         }
 #endif
 
@@ -11392,9 +12324,10 @@
         call_tests++;
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlSchemaCleanupTypes\n",
+            printf("Leak of %d blocks found in xmlSchemaCleanupTypes",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf("\n");
         }
 #endif
 
@@ -11649,9 +12582,12 @@
         des_const_xmlChar_ptr(n_str2, str2);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlStrEqual\n",
+            printf("Leak of %d blocks found in xmlStrEqual",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_str1);
+            printf(" %d", n_str2);
+            printf("\n");
         }
     }
     }
@@ -11699,9 +12635,13 @@
         des_const_xmlChar_ptr(n_str, str);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlStrQEqual\n",
+            printf("Leak of %d blocks found in xmlStrQEqual",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_pref);
+            printf(" %d", n_name);
+            printf(" %d", n_str);
+            printf("\n");
         }
     }
     }
@@ -11745,9 +12685,12 @@
         des_const_xmlChar_ptr(n_str2, str2);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlStrcasecmp\n",
+            printf("Leak of %d blocks found in xmlStrcasecmp",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_str1);
+            printf(" %d", n_str2);
+            printf("\n");
         }
     }
     }
@@ -11810,9 +12753,12 @@
         des_const_xmlChar_ptr(n_str2, str2);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlStrcmp\n",
+            printf("Leak of %d blocks found in xmlStrcmp",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_str1);
+            printf(" %d", n_str2);
+            printf("\n");
         }
     }
     }
@@ -11850,9 +12796,11 @@
         des_const_xmlChar_ptr(n_str, str);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlStrlen\n",
+            printf("Leak of %d blocks found in xmlStrlen",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_str);
+            printf("\n");
         }
     }
 
@@ -11889,9 +12837,13 @@
         des_int(n_len, len);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlStrncasecmp\n",
+            printf("Leak of %d blocks found in xmlStrncasecmp",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_str1);
+            printf(" %d", n_str2);
+            printf(" %d", n_len);
+            printf("\n");
         }
     }
     }
@@ -11950,9 +12902,13 @@
         des_int(n_len, len);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlStrncmp\n",
+            printf("Leak of %d blocks found in xmlStrncmp",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_str1);
+            printf(" %d", n_str2);
+            printf(" %d", n_len);
+            printf("\n");
         }
     }
     }
@@ -12016,9 +12972,12 @@
         des_const_xmlChar_ptr(n_utf2, utf2);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlUTF8Charcmp\n",
+            printf("Leak of %d blocks found in xmlUTF8Charcmp",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_utf1);
+            printf(" %d", n_utf2);
+            printf("\n");
         }
     }
     }
@@ -12046,9 +13005,11 @@
         des_const_xmlChar_ptr(n_utf, utf);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlUTF8Size\n",
+            printf("Leak of %d blocks found in xmlUTF8Size",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_utf);
+            printf("\n");
         }
     }
 
@@ -12075,9 +13036,11 @@
         des_const_xmlChar_ptr(n_utf, utf);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlUTF8Strlen\n",
+            printf("Leak of %d blocks found in xmlUTF8Strlen",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_utf);
+            printf("\n");
         }
     }
 
@@ -12109,9 +13072,12 @@
         des_const_xmlChar_ptr(n_utfchar, utfchar);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlUTF8Strloc\n",
+            printf("Leak of %d blocks found in xmlUTF8Strloc",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_utf);
+            printf(" %d", n_utfchar);
+            printf("\n");
         }
     }
     }
@@ -12164,9 +13130,12 @@
         des_int(n_len, len);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlUTF8Strsize\n",
+            printf("Leak of %d blocks found in xmlUTF8Strsize",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_utf);
+            printf(" %d", n_len);
+            printf("\n");
         }
     }
     }
@@ -13203,9 +14172,11 @@
         des_const_xmlChar_ptr(n_val, val);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlXPathCastStringToBoolean\n",
+            printf("Leak of %d blocks found in xmlXPathCastStringToBoolean",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_val);
+            printf("\n");
         }
     }
 #endif
@@ -13279,9 +14250,12 @@
         des_xmlNodePtr(n_node2, node2);
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlXPathCmpNodes\n",
+            printf("Leak of %d blocks found in xmlXPathCmpNodes",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf(" %d", n_node1);
+            printf(" %d", n_node2);
+            printf("\n");
         }
     }
     }
@@ -13394,9 +14368,10 @@
         call_tests++;
         xmlResetLastError();
         if (mem_base != xmlMemBlocks()) {
-            printf("Leak of %d blocks found in xmlXPathInit\n",
+            printf("Leak of %d blocks found in xmlXPathInit",
 	           xmlMemBlocks() - mem_base);
 	    ret++;
+            printf("\n");
         }
 #endif
 
diff --git a/tree.c b/tree.c
index 1eea268..87b158e 100644
--- a/tree.c
+++ b/tree.c
@@ -2154,6 +2154,7 @@
     if (content != NULL) {
 	cur->content = xmlStrdup(content);
     }
+    cur->doc = doc;
 
     if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue))
 	xmlRegisterNodeDefaultValue((xmlNodePtr)cur);
@@ -3525,10 +3526,10 @@
  */
 xmlNodePtr
 xmlReplaceNode(xmlNodePtr old, xmlNodePtr cur) {
-    if (old == NULL) {
+    if ((old == NULL) || (old->parent == NULL)) {
 #ifdef DEBUG_TREE
         xmlGenericError(xmlGenericErrorContext,
-		"xmlReplaceNode : old == NULL\n");
+		"xmlReplaceNode : old == NULL or without parent\n");
 #endif
 	return(NULL);
     }