Index: valid.c =================================================================== RCS file: /cvs/gnome/gnome-xml/valid.c,v retrieving revision 1.152 diff -c -r1.152 valid.c *** valid.c 24 Apr 2003 16:06:45 -0000 1.152 --- valid.c 5 Jun 2003 11:51:45 -0000 *************** *** 681,686 **** --- 681,716 ---- ****************************************************************/ /** + * xmlNewValidCtxt: + * + * Allocate a validation context structure. + * + * Returns NULL if not, otherwise the new validation context structure + */ + xmlValidCtxtPtr + xmlNewValidCtxt(void) { + xmlValidCtxtPtr ret; + + if ((ret = xmlMalloc(sizeof (xmlValidCtxt))) == NULL) + return (NULL); + + (void) memset(ret, 0, sizeof (xmlValidCtxt)); + + return (ret); + } + + /** + * xmlFreeValidCtxt: + * @cur: the validation context to free + * + * Free a validation context structure. + */ + void + xmlFreeValidCtxt(xmlValidCtxtPtr cur) { + xmlFree(cur); + } + + /** * xmlNewElementContent: * @name: the subelement name or NULL * @type: the type of element content decl Index: xmllint.c =================================================================== RCS file: /cvs/gnome/gnome-xml/xmllint.c,v retrieving revision 1.82 diff -c -r1.82 xmllint.c *** xmllint.c 13 May 2003 22:14:12 -0000 1.82 --- xmllint.c 5 Jun 2003 11:51:46 -0000 *************** *** 1081,1094 **** "Could not parse DTD %s\n", dtdvalid); progresult = 2; } else { ! xmlValidCtxt cvp; if ((timing) && (!repeat)) { startTimer(); } ! cvp.userData = (void *) stderr; ! cvp.error = (xmlValidityErrorFunc) fprintf; ! cvp.warning = (xmlValidityWarningFunc) fprintf; ! if (!xmlValidateDtd(&cvp, doc, dtd)) { xmlGenericError(xmlGenericErrorContext, "Document %s does not validate against %s\n", filename, dtdvalid); --- 1081,1101 ---- "Could not parse DTD %s\n", dtdvalid); progresult = 2; } else { ! xmlValidCtxtPtr cvp; ! ! if ((cvp = xmlNewValidCtxt()) == NULL) { ! xmlGenericError(xmlGenericErrorContext, ! "Couldn't allocate validation context\n"); ! exit(-1); ! } ! cvp->userData = (void *) stderr; ! cvp->error = (xmlValidityErrorFunc) fprintf; ! cvp->warning = (xmlValidityWarningFunc) fprintf; ! if ((timing) && (!repeat)) { startTimer(); } ! if (!xmlValidateDtd(cvp, doc, dtd)) { xmlGenericError(xmlGenericErrorContext, "Document %s does not validate against %s\n", filename, dtdvalid); *************** *** 1097,1113 **** if ((timing) && (!repeat)) { endTimer("Validating against DTD"); } xmlFreeDtd(dtd); } } else if (postvalid) { ! xmlValidCtxt cvp; if ((timing) && (!repeat)) { startTimer(); } ! cvp.userData = (void *) stderr; ! cvp.error = (xmlValidityErrorFunc) fprintf; ! cvp.warning = (xmlValidityWarningFunc) fprintf; ! if (!xmlValidateDocument(&cvp, doc)) { xmlGenericError(xmlGenericErrorContext, "Document %s does not validate\n", filename); progresult = 3; --- 1104,1128 ---- if ((timing) && (!repeat)) { endTimer("Validating against DTD"); } + xmlFreeValidCtxt(cvp); xmlFreeDtd(dtd); } } else if (postvalid) { ! xmlValidCtxtPtr cvp; ! ! if ((cvp = xmlNewValidCtxt()) == NULL) { ! xmlGenericError(xmlGenericErrorContext, ! "Couldn't allocate validation context\n"); ! exit(-1); ! } ! if ((timing) && (!repeat)) { startTimer(); } ! cvp->userData = (void *) stderr; ! cvp->error = (xmlValidityErrorFunc) fprintf; ! cvp->warning = (xmlValidityWarningFunc) fprintf; ! if (!xmlValidateDocument(cvp, doc)) { xmlGenericError(xmlGenericErrorContext, "Document %s does not validate\n", filename); progresult = 3; *************** *** 1115,1120 **** --- 1130,1136 ---- if ((timing) && (!repeat)) { endTimer("Validating"); } + xmlFreeValidCtxt(cvp); #ifdef LIBXML_SCHEMAS_ENABLED } else if (relaxngschemas != NULL) { xmlRelaxNGValidCtxtPtr ctxt; Index: include/libxml/valid.h =================================================================== RCS file: /cvs/gnome/gnome-xml/include/libxml/valid.h,v retrieving revision 1.40 diff -c -r1.40 valid.h *** include/libxml/valid.h 7 Apr 2003 10:22:39 -0000 1.40 --- include/libxml/valid.h 5 Jun 2003 11:51:47 -0000 *************** *** 127,132 **** --- 127,136 ---- typedef struct _xmlHashTable xmlRefTable; typedef xmlRefTable *xmlRefTablePtr; + /* Allocate/Release Validation Contexts */ + xmlValidCtxtPtr xmlNewValidCtxt(void); + void xmlFreeValidCtxt(xmlValidCtxtPtr); + /* Notation */ xmlNotationPtr xmlAddNotationDecl (xmlValidCtxtPtr ctxt, xmlDtdPtr dtd,