fixed some wording make sure doc/examples is packaged fixed the really
* Copyright: fixed some wording
* libxml.spec.in: make sure doc/examples is packaged
* include/libxml/tree.h valid.c xmlreader.c: fixed the really
annoying problem about xmlRemoveID and xmlReader streaming.
Thing looks fixed now, add to add a doc reference to the
xmlID structure though...
Daniel
diff --git a/xmlreader.c b/xmlreader.c
index c464335..6d6d558 100644
--- a/xmlreader.c
+++ b/xmlreader.c
@@ -184,6 +184,62 @@
static void xmlTextReaderFreeNodeList(xmlTextReaderPtr reader, xmlNodePtr cur);
/**
+ * xmlFreeID:
+ * @not: A id
+ *
+ * Deallocate the memory used by an id definition
+ */
+static void
+xmlFreeID(xmlIDPtr id) {
+ xmlDictPtr dict = NULL;
+
+ if (id == NULL) return;
+
+ if (id->doc != NULL)
+ dict = id->doc->dict;
+
+ if (id->value != NULL)
+ DICT_FREE(id->value)
+ xmlFree(id);
+}
+
+/**
+ * xmlTextReaderRemoveID:
+ * @doc: the document
+ * @attr: the attribute
+ *
+ * Remove the given attribute from the ID table maintained internally.
+ *
+ * Returns -1 if the lookup failed and 0 otherwise
+ */
+static int
+xmlTextReaderRemoveID(xmlDocPtr doc, xmlAttrPtr attr) {
+ xmlIDTablePtr table;
+ xmlIDPtr id;
+ xmlChar *ID;
+
+ if (doc == NULL) return(-1);
+ if (attr == NULL) return(-1);
+ table = (xmlIDTablePtr) doc->ids;
+ if (table == NULL)
+ return(-1);
+
+ if (attr == NULL)
+ return(-1);
+ ID = xmlNodeListGetString(doc, attr->children, 1);
+ if (ID == NULL)
+ return(-1);
+ id = xmlHashLookup(table, ID);
+ xmlFree(ID);
+ if (id == NULL || id->attr != attr) {
+ return(-1);
+ }
+ id->name = attr->name;
+ id->attr = NULL;
+ return(0);
+}
+
+/**
* xmlTextReaderFreeProp:
* @reader: the xmlTextReaderPtr used
* @cur: the node
@@ -202,7 +258,7 @@
((cur->parent->doc->intSubset != NULL) ||
(cur->parent->doc->extSubset != NULL))) {
if (xmlIsID(cur->parent->doc, cur->parent, cur))
- xmlRemoveID(cur->parent->doc, cur);
+ xmlTextReaderRemoveID(cur->parent->doc, cur);
}
if (cur->children != NULL)
xmlTextReaderFreeNodeList(reader, cur->children);
@@ -377,6 +433,17 @@
}
/**
+ * xmlTextReaderFreeIDTable:
+ * @table: An id table
+ *
+ * Deallocate the memory used by an ID hash table.
+ */
+void
+xmlTextReaderFreeIDTable(xmlIDTablePtr table) {
+ xmlHashFree(table, (xmlHashDeallocator) xmlFreeID);
+}
+
+/**
* xmlTextReaderFreeDoc:
* @reader: the xmlTextReaderPtr used
* @cur: pointer to the document
@@ -392,7 +459,7 @@
/*
* Do this before freeing the children list to avoid ID lookups
*/
- if (cur->ids != NULL) xmlFreeIDTable((xmlIDTablePtr) cur->ids);
+ if (cur->ids != NULL) xmlTextReaderFreeIDTable((xmlIDTablePtr) cur->ids);
cur->ids = NULL;
if (cur->refs != NULL) xmlFreeRefTable((xmlRefTablePtr) cur->refs);
cur->refs = NULL;