1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-10-26 00:37:43 +03:00

A bit of cleanups

* tree.c: avoid calling xmlAddID with NULL values
* parser.c: add a few xmlInitParser in some entry points
This commit is contained in:
Daniel Veillard
2009-07-09 08:45:03 +02:00
parent bccae2d210
commit ab2a763db8
3 changed files with 16 additions and 6 deletions

View File

@@ -13568,6 +13568,8 @@ xmlSAXParseMemoryWithData(xmlSAXHandlerPtr sax, const char *buffer,
xmlDocPtr ret;
xmlParserCtxtPtr ctxt;
xmlInitParser();
ctxt = xmlCreateMemoryParserCtxt(buffer, size);
if (ctxt == NULL) return(NULL);
if (sax != NULL) {
@@ -13593,7 +13595,7 @@ xmlSAXParseMemoryWithData(xmlSAXHandlerPtr sax, const char *buffer,
if (sax != NULL)
ctxt->sax = NULL;
xmlFreeParserCtxt(ctxt);
return(ret);
}
@@ -13656,14 +13658,16 @@ xmlDocPtr xmlRecoverMemory(const char *buffer, int size) {
*
* A better SAX parsing routine.
* parse an XML in-memory buffer and call the given SAX handler routines.
*
*
* Returns 0 in case of success or a error number otherwise
*/
int xmlSAXUserParseMemory(xmlSAXHandlerPtr sax, void *user_data,
const char *buffer, int size) {
int ret = 0;
xmlParserCtxtPtr ctxt;
xmlInitParser();
ctxt = xmlCreateMemoryParserCtxt(buffer, size);
if (ctxt == NULL) return -1;
if (ctxt->sax != (xmlSAXHandlerPtr) &xmlDefaultSAXHandler)
@@ -13673,7 +13677,7 @@ int xmlSAXUserParseMemory(xmlSAXHandlerPtr sax, void *user_data,
if (user_data != NULL)
ctxt->userData = user_data;
xmlParseDocument(ctxt);
if (ctxt->wellFormed)