Permalink
Browse files

warning patches from Peter Breitenlohner serious DTD parsing speedups,

* testdso.c xmlregexp.c: warning patches from Peter Breitenlohner
* include/libxml/valid.h valid.c parser.c: serious DTD parsing
  speedups, start to deprecate 3 ElementDef related entry point
  and replace them with better ones.
Daniel
  • Loading branch information...
1 parent b9e2f26 commit cee2b3a5f124e19db46109132c22e1b8faec1c87 Daniel Veillard committed Jan 25, 2005
Showing with 287 additions and 89 deletions.
  1. +7 −0 ChangeLog
  2. +12 −0 include/libxml/valid.h
  3. +40 −26 parser.c
  4. +3 −1 testdso.c
  5. +223 −60 valid.c
  6. +2 −2 xmlregexp.c
View
@@ -1,3 +1,10 @@
+Tue Jan 25 01:20:11 CET 2005 Daniel Veillard <daniel@veillard.com>
+
+ * testdso.c xmlregexp.c: warning patches from Peter Breitenlohner
+ * include/libxml/valid.h valid.c parser.c: serious DTD parsing
+ speedups, start to deprecate 3 ElementDef related entry point
+ and replace them with better ones.
+
Mon Jan 24 00:47:41 CET 2005 Daniel Veillard <daniel@veillard.com>
* xmlschemas.c: more hash dictionary interning changes
@@ -172,13 +172,25 @@ XMLPUBFUN void XMLCALL
#endif /* LIBXML_OUTPUT_ENABLED */
/* Element Content */
+/* the non Doc version are being deprecated */
XMLPUBFUN xmlElementContentPtr XMLCALL
xmlNewElementContent (const xmlChar *name,
xmlElementContentType type);
XMLPUBFUN xmlElementContentPtr XMLCALL
xmlCopyElementContent (xmlElementContentPtr content);
XMLPUBFUN void XMLCALL
xmlFreeElementContent (xmlElementContentPtr cur);
+/* the new versions with doc argument */
+XMLPUBFUN xmlElementContentPtr XMLCALL
+ xmlNewDocElementContent (xmlDocPtr doc,
+ const xmlChar *name,
+ xmlElementContentType type);
+XMLPUBFUN xmlElementContentPtr XMLCALL
+ xmlCopyDocElementContent(xmlDocPtr doc,
+ xmlElementContentPtr content);
+XMLPUBFUN void XMLCALL
+ xmlFreeDocElementContent(xmlDocPtr doc,
+ xmlElementContentPtr cur);
XMLPUBFUN void XMLCALL
xmlSnprintfElementContent(char *buf,
int size,
View
@@ -4739,30 +4739,30 @@ xmlParseElementMixedContentDecl(xmlParserCtxtPtr ctxt, int inputchk) {
NULL);
}
NEXT;
- ret = xmlNewElementContent(NULL, XML_ELEMENT_CONTENT_PCDATA);
+ ret = xmlNewDocElementContent(ctxt->myDoc, NULL, XML_ELEMENT_CONTENT_PCDATA);
if (RAW == '*') {
ret->ocur = XML_ELEMENT_CONTENT_MULT;
NEXT;
}
return(ret);
}
if ((RAW == '(') || (RAW == '|')) {
- ret = cur = xmlNewElementContent(NULL, XML_ELEMENT_CONTENT_PCDATA);
+ ret = cur = xmlNewDocElementContent(ctxt->myDoc, NULL, XML_ELEMENT_CONTENT_PCDATA);
if (ret == NULL) return(NULL);
}
while (RAW == '|') {
NEXT;
if (elem == NULL) {
- ret = xmlNewElementContent(NULL, XML_ELEMENT_CONTENT_OR);
+ ret = xmlNewDocElementContent(ctxt->myDoc, NULL, XML_ELEMENT_CONTENT_OR);
if (ret == NULL) return(NULL);
ret->c1 = cur;
if (cur != NULL)
cur->parent = ret;
cur = ret;
} else {
- n = xmlNewElementContent(NULL, XML_ELEMENT_CONTENT_OR);
+ n = xmlNewDocElementContent(ctxt->myDoc, NULL, XML_ELEMENT_CONTENT_OR);
if (n == NULL) return(NULL);
- n->c1 = xmlNewElementContent(elem, XML_ELEMENT_CONTENT_ELEMENT);
+ n->c1 = xmlNewDocElementContent(ctxt->myDoc, elem, XML_ELEMENT_CONTENT_ELEMENT);
if (n->c1 != NULL)
n->c1->parent = n;
cur->c2 = n;
@@ -4775,15 +4775,15 @@ xmlParseElementMixedContentDecl(xmlParserCtxtPtr ctxt, int inputchk) {
if (elem == NULL) {
xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
"xmlParseElementMixedContentDecl : Name expected\n");
- xmlFreeElementContent(cur);
+ xmlFreeDocElementContent(ctxt->myDoc, cur);
return(NULL);
}
SKIP_BLANKS;
GROW;
}
if ((RAW == ')') && (NXT(1) == '*')) {
if (elem != NULL) {
- cur->c2 = xmlNewElementContent(elem,
+ cur->c2 = xmlNewDocElementContent(ctxt->myDoc, elem,
XML_ELEMENT_CONTENT_ELEMENT);
if (cur->c2 != NULL)
cur->c2->parent = cur;
@@ -4796,7 +4796,7 @@ xmlParseElementMixedContentDecl(xmlParserCtxtPtr ctxt, int inputchk) {
}
SKIP(2);
} else {
- xmlFreeElementContent(ret);
+ xmlFreeDocElementContent(ctxt->myDoc, ret);
xmlFatalErr(ctxt, XML_ERR_MIXED_NOT_STARTED, NULL);
return(NULL);
}
@@ -4861,7 +4861,7 @@ xmlParseElementChildrenContentDecl (xmlParserCtxtPtr ctxt, int inputchk) {
xmlFatalErr(ctxt, XML_ERR_ELEMCONTENT_NOT_STARTED, NULL);
return(NULL);
}
- cur = ret = xmlNewElementContent(elem, XML_ELEMENT_CONTENT_ELEMENT);
+ cur = ret = xmlNewDocElementContent(ctxt->myDoc, elem, XML_ELEMENT_CONTENT_ELEMENT);
if (cur == NULL) {
xmlErrMemory(ctxt, NULL);
return(NULL);
@@ -4898,18 +4898,18 @@ xmlParseElementChildrenContentDecl (xmlParserCtxtPtr ctxt, int inputchk) {
"xmlParseElementChildrenContentDecl : '%c' expected\n",
type);
if ((last != NULL) && (last != ret))
- xmlFreeElementContent(last);
+ xmlFreeDocElementContent(ctxt->myDoc, last);
if (ret != NULL)
- xmlFreeElementContent(ret);
+ xmlFreeDocElementContent(ctxt->myDoc, ret);
return(NULL);
}
NEXT;
- op = xmlNewElementContent(NULL, XML_ELEMENT_CONTENT_SEQ);
+ op = xmlNewDocElementContent(ctxt->myDoc, NULL, XML_ELEMENT_CONTENT_SEQ);
if (op == NULL) {
if ((last != NULL) && (last != ret))
- xmlFreeElementContent(last);
- xmlFreeElementContent(ret);
+ xmlFreeDocElementContent(ctxt->myDoc, last);
+ xmlFreeDocElementContent(ctxt->myDoc, ret);
return(NULL);
}
if (last == NULL) {
@@ -4938,19 +4938,19 @@ xmlParseElementChildrenContentDecl (xmlParserCtxtPtr ctxt, int inputchk) {
"xmlParseElementChildrenContentDecl : '%c' expected\n",
type);
if ((last != NULL) && (last != ret))
- xmlFreeElementContent(last);
+ xmlFreeDocElementContent(ctxt->myDoc, last);
if (ret != NULL)
- xmlFreeElementContent(ret);
+ xmlFreeDocElementContent(ctxt->myDoc, ret);
return(NULL);
}
NEXT;
- op = xmlNewElementContent(NULL, XML_ELEMENT_CONTENT_OR);
+ op = xmlNewDocElementContent(ctxt->myDoc, NULL, XML_ELEMENT_CONTENT_OR);
if (op == NULL) {
if ((last != NULL) && (last != ret))
- xmlFreeElementContent(last);
+ xmlFreeDocElementContent(ctxt->myDoc, last);
if (ret != NULL)
- xmlFreeElementContent(ret);
+ xmlFreeDocElementContent(ctxt->myDoc, ret);
return(NULL);
}
if (last == NULL) {
@@ -4971,7 +4971,7 @@ xmlParseElementChildrenContentDecl (xmlParserCtxtPtr ctxt, int inputchk) {
} else {
xmlFatalErr(ctxt, XML_ERR_ELEMCONTENT_NOT_FINISHED, NULL);
if (ret != NULL)
- xmlFreeElementContent(ret);
+ xmlFreeDocElementContent(ctxt->myDoc, ret);
return(NULL);
}
GROW;
@@ -4989,10 +4989,10 @@ xmlParseElementChildrenContentDecl (xmlParserCtxtPtr ctxt, int inputchk) {
if (elem == NULL) {
xmlFatalErr(ctxt, XML_ERR_ELEMCONTENT_NOT_STARTED, NULL);
if (ret != NULL)
- xmlFreeElementContent(ret);
+ xmlFreeDocElementContent(ctxt->myDoc, ret);
return(NULL);
}
- last = xmlNewElementContent(elem, XML_ELEMENT_CONTENT_ELEMENT);
+ last = xmlNewDocElementContent(ctxt->myDoc, elem, XML_ELEMENT_CONTENT_ELEMENT);
if (RAW == '?') {
last->ocur = XML_ELEMENT_CONTENT_OPT;
NEXT;
@@ -5213,6 +5213,9 @@ xmlParseElementDecl(xmlParserCtxtPtr ctxt) {
if (RAW != '>') {
xmlFatalErr(ctxt, XML_ERR_GT_REQUIRED, NULL);
+ if (content != NULL) {
+ xmlFreeDocElementContent(ctxt->myDoc, content);
+ }
} else {
if (input != ctxt->input) {
xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
@@ -5221,12 +5224,23 @@ xmlParseElementDecl(xmlParserCtxtPtr ctxt) {
NEXT;
if ((ctxt->sax != NULL) && (!ctxt->disableSAX) &&
- (ctxt->sax->elementDecl != NULL))
+ (ctxt->sax->elementDecl != NULL)) {
+ if (content != NULL)
+ content->parent = NULL;
ctxt->sax->elementDecl(ctxt->userData, name, ret,
content);
- }
- if (content != NULL) {
- xmlFreeElementContent(content);
+ if ((content != NULL) && (content->parent == NULL)) {
+ /*
+ * this is a trick: if xmlAddElementDecl is called,
+ * instead of copying the full tree it is plugged directly
+ * if called from the parser. Avoid duplicating the
+ * interfaces or change the API/ABI
+ */
+ xmlFreeDocElementContent(ctxt->myDoc, content);
+ }
+ } else if (content != NULL) {
+ xmlFreeDocElementContent(ctxt->myDoc, content);
+ }
}
}
return(ret);
View
@@ -3,7 +3,9 @@
#define IN_LIBXML
#include "libxml/xmlexports.h"
-XMLPUBFUN int hello_world(void)
+XMLPUBFUN int hello_world(void);
+
+int hello_world(void)
{
printf("Success!\n");
return 0;
Oops, something went wrong.

0 comments on commit cee2b3a

Please sign in to comment.