From ddbf47a33aa4fba4ce23e751db78acf59895fcc3 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sat, 28 Jul 2007 20:41:41 +0000 Subject: Finalisation and destruction of nodes svn path=/trunk/dom/; revision=3467 --- src/core/attr.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'src/core/attr.c') diff --git a/src/core/attr.c b/src/core/attr.c index ed20c93..ca6047a 100644 --- a/src/core/attr.c +++ b/src/core/attr.c @@ -79,6 +79,53 @@ dom_exception dom_attr_create(struct dom_document *doc, return DOM_NO_ERR; } +/** + * Destroy an attribute node + * + * \param doc The owning document + * \param attr The attribute to destroy + * + * The contents of ::attr will be destroyed and ::attr will be freed + */ +void dom_attr_destroy(struct dom_document *doc, struct dom_attr *attr) +{ + struct dom_node *c, *d; + + /* Destroy children of this node */ + for (c = attr->base.first_child; c != NULL; c = d) { + d = c->next; + + /* Detach child */ + c->parent = NULL; + + if (c->refcnt > 0) { + /* Something is using this child */ + + /** \todo add to list of nodes pending deletion */ + + continue; + } + + /* Detach from sibling list */ + c->previous = NULL; + c->next = NULL; + + dom_node_destroy(c); + } + + /* Now, clean up this node and destroy it */ + + if (attr->schema_type_info != NULL) { + /** \todo destroy schema type info */ + } + + attr->owner = NULL; + + dom_node_finalise(doc, &attr->base); + + dom_document_alloc(doc, attr, 0); +} + /** * Retrieve an attribute's name * -- cgit v1.2.3