From 704b77565e0108982d2e2a26f572ce0b3eb85170 Mon Sep 17 00:00:00 2001 From: Bo Yang Date: Mon, 17 Aug 2009 10:47:47 +0000 Subject: Split the _dom_element_destroy into two functions. svn path=/trunk/dom/; revision=9330 --- src/core/element.c | 41 ++++++++++++++++++++++++++--------------- src/core/element.h | 2 ++ 2 files changed, 28 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/core/element.c b/src/core/element.c index 3b91e5f..eb76bc7 100644 --- a/src/core/element.c +++ b/src/core/element.c @@ -209,37 +209,48 @@ dom_exception _dom_element_initialise(struct dom_document *doc, } /** - * Destroy an element - * - * \param doc The owning document - * \param element The element to destroy + * Finalise a dom_element * - * The contents of ::element will be destroyed and ::element will be freed. + * \param doc The document + * \param ele The element */ -void _dom_element_destroy(struct dom_document *doc, - struct dom_element *element) +void _dom_element_finalise(struct dom_document *doc, struct dom_element *ele) { lwc_context *ctx = _dom_document_get_intern_context(doc); assert (ctx != NULL); /* Destroy attributes attached to this node */ - if (element->attributes != NULL) { - _dom_hash_destroy(element->attributes, _key, ctx, _value, ctx); - element->attributes = NULL; + if (ele->attributes != NULL) { + _dom_hash_destroy(ele->attributes, _key, ctx, _value, ctx); + ele->attributes = NULL; } - if (element->ns_attributes != NULL) { - _dom_hash_destroy(element->ns_attributes, _key, ctx, + if (ele->ns_attributes != NULL) { + _dom_hash_destroy(ele->ns_attributes, _key, ctx, _nsattributes, ctx); - element->ns_attributes = NULL; + ele->ns_attributes = NULL; } - if (element->schema_type_info != NULL) { + if (ele->schema_type_info != NULL) { /** \todo destroy schema type info */ } /* Finalise base class */ - _dom_node_finalise(doc, &element->base); + _dom_node_finalise(doc, &ele->base); +} + +/** + * Destroy an element + * + * \param doc The owning document + * \param element The element to destroy + * + * The contents of ::element will be destroyed and ::element will be freed. + */ +void _dom_element_destroy(struct dom_document *doc, + struct dom_element *element) +{ + _dom_element_finalise(doc, element); /* Free the element */ _dom_document_alloc(doc, element, 0); diff --git a/src/core/element.h b/src/core/element.h index a5e338a..51e1268 100644 --- a/src/core/element.h +++ b/src/core/element.h @@ -47,6 +47,8 @@ dom_exception _dom_element_initialise(struct dom_document *doc, struct dom_element *el, struct lwc_string_s *name, struct lwc_string_s *namespace, struct lwc_string_s *prefix); +void _dom_element_finalise(struct dom_document *doc, struct dom_element *ele); + void _dom_element_destroy(struct dom_document *doc, struct dom_element *element); -- cgit v1.2.3