summaryrefslogtreecommitdiff
path: root/xmlwriter.c
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@src.gnome.org>2004-11-09 14:59:59 +0000
committerDaniel Veillard <veillard@src.gnome.org>2004-11-09 14:59:59 +0000
commita521d287516f2dc93a8fe540c5883ffc39cb5024 (patch)
treea291ab9424274ed29a15909fb643a2e9370141e4 /xmlwriter.c
parent645a924a9d50d8e0eced5dd7277214a65756c2e1 (diff)
downloadlibxml2-a521d287516f2dc93a8fe540c5883ffc39cb5024.tar.gz
better handling of conditional features more testing on parser contexts
* gentest.py testapi.c: better handling of conditional features * HTMLparser.c SAX2.c parserInternals.c xmlwriter.c: more testing on parser contexts closed leaks, error messages Daniel
Diffstat (limited to 'xmlwriter.c')
-rw-r--r--xmlwriter.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/xmlwriter.c b/xmlwriter.c
index 4b2c3e11..3255c674 100644
--- a/xmlwriter.c
+++ b/xmlwriter.c
@@ -71,6 +71,7 @@ struct _xmlTextWriter {
xmlChar *ichar; /* indent character */
char qchar; /* character used for quoting attribute values */
xmlParserCtxtPtr ctxt;
+ int no_doc_free;
};
static void xmlFreeTextWriterStackEntry(xmlLinkPtr lk);
@@ -198,6 +199,7 @@ xmlNewTextWriter(xmlOutputBufferPtr out)
"xmlNewTextWriter : out of memory!\n");
return NULL;
}
+ ret->no_doc_free = 0;
return ret;
}
@@ -376,8 +378,10 @@ xmlNewTextWriterDoc(xmlDocPtr * doc, int compression)
xmlSetDocCompressMode(ctxt->myDoc, compression);
- if (doc != NULL)
+ if (doc != NULL) {
*doc = ctxt->myDoc;
+ ret->no_doc_free = 1;
+ }
return ret;
}
@@ -434,6 +438,7 @@ xmlNewTextWriterTree(xmlDocPtr doc, xmlNodePtr node, int compression)
ctxt->myDoc = doc;
ctxt->node = node;
+ ret->no_doc_free = 1;
xmlSetDocCompressMode(doc, compression);
@@ -461,8 +466,13 @@ xmlFreeTextWriter(xmlTextWriterPtr writer)
if (writer->nsstack != NULL)
xmlListDelete(writer->nsstack);
- if (writer->ctxt != NULL)
+ if (writer->ctxt != NULL) {
+ if ((writer->ctxt->myDoc != NULL) && (writer->no_doc_free == 0)) {
+ xmlFreeDoc(writer->ctxt->myDoc);
+ writer->ctxt->myDoc = NULL;
+ }
xmlFreeParserCtxt(writer->ctxt);
+ }
if (writer->ichar != NULL)
xmlFree(writer->ichar);