diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2007-07-28 20:41:41 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2007-07-28 20:41:41 +0000 |
commit | ddbf47a33aa4fba4ce23e751db78acf59895fcc3 (patch) | |
tree | 08ff52e60d85dd31ef7f22c5792cf7794eeb8736 /src/core/doc_fragment.c | |
parent | f6b4e5eeaf8e7afda0df4a5d44a309c291788382 (diff) | |
download | libdom-ddbf47a33aa4fba4ce23e751db78acf59895fcc3.tar.gz libdom-ddbf47a33aa4fba4ce23e751db78acf59895fcc3.tar.bz2 |
Finalisation and destruction of nodes
svn path=/trunk/dom/; revision=3467
Diffstat (limited to 'src/core/doc_fragment.c')
-rw-r--r-- | src/core/doc_fragment.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/core/doc_fragment.c b/src/core/doc_fragment.c index 0792467..eaef388 100644 --- a/src/core/doc_fragment.c +++ b/src/core/doc_fragment.c @@ -55,3 +55,45 @@ dom_exception dom_document_fragment_create(struct dom_document *doc, return DOM_NO_ERR; } + +/** + * Destroy a document fragment + * + * \param doc The owning document + * \param frag The document fragment to destroy + * + * The contents of ::frag will be destroyed and ::frag will be freed. + */ +void dom_document_fragment_destroy(struct dom_document *doc, + struct dom_document_fragment *frag) +{ + struct dom_node *c, *d; + + /* Destroy children of this node */ + for (c = frag->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); + } + + /* Finalise base class */ + dom_node_finalise(doc, &frag->base); + + /* Destroy fragment */ + dom_document_alloc(doc, frag, 0); +} |