summaryrefslogtreecommitdiff
path: root/src/core/comment.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2011-12-21 22:18:10 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2011-12-21 22:18:10 +0000
commit83f3338663c4969eebefd8c2c43bd3fc43587fdd (patch)
treee48ba69628c5ba793533094e308c1fce9acb21aa /src/core/comment.c
parent4ade8ad1c7b23e6eeeee6681acbdb43fb10cab43 (diff)
downloadlibdom-83f3338663c4969eebefd8c2c43bd3fc43587fdd.tar.gz
libdom-83f3338663c4969eebefd8c2c43bd3fc43587fdd.tar.bz2
Merge branches/jmb/dom-alloc-purge back to trunk
svn path=/trunk/libdom/; revision=13316
Diffstat (limited to 'src/core/comment.c')
-rw-r--r--src/core/comment.c65
1 files changed, 30 insertions, 35 deletions
diff --git a/src/core/comment.c b/src/core/comment.c
index ab49a66..0697826 100644
--- a/src/core/comment.c
+++ b/src/core/comment.c
@@ -6,6 +6,8 @@
* Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
*/
+#include <stdlib.h>
+
#include "core/characterdata.h"
#include "core/comment.h"
#include "core/document.h"
@@ -16,7 +18,7 @@
* A DOM Comment node
*/
struct dom_comment {
- struct dom_characterdata base; /**< Base node */
+ dom_characterdata base; /**< Base node */
};
static struct dom_node_protect_vtable comment_protect_vtable = {
@@ -37,15 +39,15 @@ static struct dom_node_protect_vtable comment_protect_vtable = {
*
* The returned node will already be referenced.
*/
-dom_exception _dom_comment_create(struct dom_document *doc,
- struct lwc_string_s *name, dom_string *value,
- struct dom_comment **result)
+dom_exception _dom_comment_create(dom_document *doc,
+ dom_string *name, dom_string *value,
+ dom_comment **result)
{
- struct dom_comment *c;
+ dom_comment *c;
dom_exception err;
/* Allocate the comment node */
- c = _dom_document_alloc(doc, NULL, sizeof(struct dom_comment));
+ c = malloc(sizeof(dom_comment));
if (c == NULL)
return DOM_NO_MEM_ERR;
@@ -57,7 +59,7 @@ dom_exception _dom_comment_create(struct dom_document *doc,
err = _dom_characterdata_initialise(&c->base, doc, DOM_COMMENT_NODE,
name, value);
if (err != DOM_NO_ERR) {
- _dom_document_alloc(doc, c, 0);
+ free(c);
return err;
}
@@ -69,19 +71,17 @@ dom_exception _dom_comment_create(struct dom_document *doc,
/**
* Destroy a comment node
*
- * \param doc The owning document
* \param comment The node to destroy
*
* The contents of ::comment will be destroyed and ::comment will be freed
*/
-void _dom_comment_destroy(struct dom_document *doc,
- struct dom_comment *comment)
+void _dom_comment_destroy(dom_comment *comment)
{
/* Finalise base class contents */
- _dom_characterdata_finalise(doc, &comment->base);
+ _dom_characterdata_finalise(&comment->base);
/* Free node */
- _dom_document_alloc(doc, comment, 0);
+ free(comment);
}
@@ -89,35 +89,30 @@ void _dom_comment_destroy(struct dom_document *doc,
/* The protected virtual functions */
/* The virtual destroy function */
-void __dom_comment_destroy(struct dom_node_internal *node)
+void __dom_comment_destroy(dom_node_internal *node)
{
- struct dom_document *doc;
- doc = dom_node_get_owner(node);
-
- _dom_comment_destroy(doc, (struct dom_comment *) node);
+ _dom_comment_destroy((dom_comment *) node);
}
-/* The memory allocation function of this class */
-dom_exception _dom_comment_alloc(struct dom_document *doc,
- struct dom_node_internal *n, struct dom_node_internal **ret)
+/* The copy constructor of this class */
+dom_exception _dom_comment_copy(dom_node_internal *old,
+ dom_node_internal **copy)
{
- UNUSED(n);
- dom_comment *c;
-
- c = _dom_document_alloc(doc, NULL, sizeof(struct dom_comment));
- if (c == NULL)
+ dom_comment *new_comment;
+ dom_exception err;
+
+ new_comment = malloc(sizeof(dom_comment));
+ if (new_comment == NULL)
return DOM_NO_MEM_ERR;
-
- *ret = (dom_node_internal *) c;
- dom_node_set_owner(*ret, doc);
- return DOM_NO_ERR;
-}
+ err = dom_characterdata_copy_internal(old, new_comment);
+ if (err != DOM_NO_ERR) {
+ free(new_comment);
+ return err;
+ }
-/* The copy constructor of this class */
-dom_exception _dom_comment_copy(struct dom_node_internal *new,
- struct dom_node_internal *old)
-{
- return _dom_characterdata_copy(new, old);
+ *copy = (dom_node_internal *) new_comment;
+
+ return DOM_NO_ERR;
}