summaryrefslogtreecommitdiff
path: root/src/core/cdatasection.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/cdatasection.c')
-rw-r--r--src/core/cdatasection.c65
1 files changed, 30 insertions, 35 deletions
diff --git a/src/core/cdatasection.c b/src/core/cdatasection.c
index 7417ebf..fd10c3a 100644
--- a/src/core/cdatasection.c
+++ b/src/core/cdatasection.c
@@ -6,6 +6,8 @@
* Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
*/
+#include <stdlib.h>
+
#include "core/cdatasection.h"
#include "core/document.h"
#include "core/text.h"
@@ -15,7 +17,7 @@
* A DOM CDATA section
*/
struct dom_cdata_section {
- struct dom_text base; /**< Base node */
+ dom_text base; /**< Base node */
};
static struct dom_node_protect_vtable cdata_section_protect_vtable = {
@@ -36,15 +38,15 @@ static struct dom_node_protect_vtable cdata_section_protect_vtable = {
*
* The returned node will already be referenced.
*/
-dom_exception _dom_cdata_section_create(struct dom_document *doc,
- struct lwc_string_s *name, dom_string *value,
- struct dom_cdata_section **result)
+dom_exception _dom_cdata_section_create(dom_document *doc,
+ dom_string *name, dom_string *value,
+ dom_cdata_section **result)
{
- struct dom_cdata_section *c;
+ dom_cdata_section *c;
dom_exception err;
/* Allocate the comment node */
- c = _dom_document_alloc(doc, NULL, sizeof(struct dom_cdata_section));
+ c = malloc(sizeof(dom_cdata_section));
if (c == NULL)
return DOM_NO_MEM_ERR;
@@ -56,7 +58,7 @@ dom_exception _dom_cdata_section_create(struct dom_document *doc,
err = _dom_cdata_section_initialise(&c->base, doc,
DOM_CDATA_SECTION_NODE, name, value);
if (err != DOM_NO_ERR) {
- _dom_document_alloc(doc, c, 0);
+ free(c);
return err;
}
@@ -68,19 +70,17 @@ dom_exception _dom_cdata_section_create(struct dom_document *doc,
/**
* Destroy a CDATA section
*
- * \param doc The owning document
* \param cdata The cdata section to destroy
*
* The contents of ::cdata will be destroyed and ::cdata will be freed.
*/
-void _dom_cdata_section_destroy(struct dom_document *doc,
- struct dom_cdata_section *cdata)
+void _dom_cdata_section_destroy(dom_cdata_section *cdata)
{
/* Clean up base node contents */
- _dom_cdata_section_finalise(doc, &cdata->base);
+ _dom_cdata_section_finalise(&cdata->base);
/* Destroy the node */
- _dom_document_alloc(doc, cdata, 0);
+ free(cdata);
}
/*--------------------------------------------------------------------------*/
@@ -88,35 +88,30 @@ void _dom_cdata_section_destroy(struct dom_document *doc,
/* The protected virtual functions */
/* The virtual destroy function of this class */
-void __dom_cdata_section_destroy(struct dom_node_internal *node)
+void __dom_cdata_section_destroy(dom_node_internal *node)
{
- struct dom_document *doc;
- doc = dom_node_get_owner(node);
-
- _dom_cdata_section_destroy(doc, (struct dom_cdata_section *) node);
+ _dom_cdata_section_destroy((dom_cdata_section *) node);
}
-/* The memory allocator of this class */
-dom_exception _dom_cdata_section_alloc(struct dom_document *doc,
- struct dom_node_internal *n, struct dom_node_internal **ret)
+/* The copy constructor of this class */
+dom_exception _dom_cdata_section_copy(dom_node_internal *old,
+ dom_node_internal **copy)
{
- UNUSED(n);
- dom_cdata_section *a;
-
- a = _dom_document_alloc(doc, NULL, sizeof(struct dom_cdata_section));
- if (a == NULL)
+ dom_cdata_section *new_cdata;
+ dom_exception err;
+
+ new_cdata = malloc(sizeof(dom_cdata_section));
+ if (new_cdata == NULL)
return DOM_NO_MEM_ERR;
-
- *ret = (dom_node_internal *) a;
- dom_node_set_owner(*ret, doc);
- return DOM_NO_ERR;
-}
+ err = dom_text_copy_internal(old, new_cdata);
+ if (err != DOM_NO_ERR) {
+ free(new_cdata);
+ return err;
+ }
-/* The copy constructor of this class */
-dom_exception _dom_cdata_section_copy(struct dom_node_internal *new,
- struct dom_node_internal *old)
-{
- return _dom_characterdata_copy(new, old);
+ *copy = (dom_node_internal *) new_cdata;
+
+ return DOM_NO_ERR;
}