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 | bb9a9029b6ec4f26ee31f4879cde52d58dcb49c0 (patch) | |
tree | 08ff52e60d85dd31ef7f22c5792cf7794eeb8736 /src/core/entity_ref.c | |
parent | 5b357e92a1cf9c515ec73e7bb6a4ff396aca6cf5 (diff) | |
download | libdom-bb9a9029b6ec4f26ee31f4879cde52d58dcb49c0.tar.gz libdom-bb9a9029b6ec4f26ee31f4879cde52d58dcb49c0.tar.bz2 |
Finalisation and destruction of nodes
svn path=/trunk/dom/; revision=3467
Diffstat (limited to 'src/core/entity_ref.c')
-rw-r--r-- | src/core/entity_ref.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/core/entity_ref.c b/src/core/entity_ref.c index 7bc103e..8382249 100644 --- a/src/core/entity_ref.c +++ b/src/core/entity_ref.c @@ -55,3 +55,45 @@ dom_exception dom_entity_reference_create(struct dom_document *doc, return DOM_NO_ERR; } + +/** + * Destroy an entity reference + * + * \param doc The owning document + * \param entity The entity reference to destroy + * + * The contents of ::entity will be destroyed and ::entity will be freed. + */ +void dom_entity_reference_destroy(struct dom_document *doc, + struct dom_entity_reference *entity) +{ + struct dom_node *c, *d; + + /* Destroy children of this node */ + for (c = entity->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, &entity->base); + + /* Destroy fragment */ + dom_document_alloc(doc, entity, 0); +} |