summaryrefslogtreecommitdiff
path: root/src/core/nodelist.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2007-07-10 23:25:18 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2007-07-10 23:25:18 +0000
commit8c37c8567d24d94636cff13bab4eebd9ae690ca2 (patch)
treeb4c493587d97605e69be27b7cd7850ef3bb2a3ac /src/core/nodelist.c
parentacfc9fd1b44f7b72ba66705daf34914940509793 (diff)
downloadlibdom-8c37c8567d24d94636cff13bab4eebd9ae690ca2.tar.gz
libdom-8c37c8567d24d94636cff13bab4eebd9ae690ca2.tar.bz2
Add NamedNodeMap.
Minor fix for NodeList unref function; ensure it unrefs the owner document after it has finished using it. svn path=/trunk/dom/; revision=3395
Diffstat (limited to 'src/core/nodelist.c')
-rw-r--r--src/core/nodelist.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/core/nodelist.c b/src/core/nodelist.c
index 1fff561..b37b84e 100644
--- a/src/core/nodelist.c
+++ b/src/core/nodelist.c
@@ -62,7 +62,7 @@ struct dom_nodelist {
* will match the children of ::root.
*
* The returned list will already be referenced, so the client need not
- * do so explicitly. The client should unref the list once finished with it.
+ * do so explicitly. The client must unref the list once finished with it.
*/
dom_exception dom_nodelist_create(struct dom_document *doc,
struct dom_node *root, struct dom_string *tagname,
@@ -124,6 +124,8 @@ void dom_nodelist_ref(struct dom_nodelist *list)
void dom_nodelist_unref(struct dom_nodelist *list)
{
if (--list->refcnt == 0) {
+ struct dom_node *owner = (struct dom_node *) list->owner;
+
switch (list->type) {
case DOM_NODELIST_CHILDREN:
/* Nothing to do */
@@ -139,13 +141,16 @@ void dom_nodelist_unref(struct dom_nodelist *list)
dom_node_unref(list->root);
- dom_node_unref((struct dom_node *) list->owner);
-
/* Remove list from document */
dom_document_remove_nodelist(list->owner, list);
- /* And destroy the list object */
+ /* Destroy the list object */
dom_document_alloc(list->owner, list, 0);
+
+ /* And release our reference on the owning document
+ * This must be last as, otherwise, it's possible that
+ * the document is destroyed before we are */
+ dom_node_unref(owner);
}
}