summaryrefslogtreecommitdiff
path: root/src/core/pi.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/pi.c')
-rw-r--r--src/core/pi.c68
1 files changed, 33 insertions, 35 deletions
diff --git a/src/core/pi.c b/src/core/pi.c
index 1d7a508..d12f109 100644
--- a/src/core/pi.c
+++ b/src/core/pi.c
@@ -5,6 +5,8 @@
* Copyright 2007 John-Mark Bell <jmb@netsurf-browser.org>
*/
+#include <stdlib.h>
+
#include "core/document.h"
#include "core/node.h"
#include "core/pi.h"
@@ -15,10 +17,13 @@
* A DOM processing instruction
*/
struct dom_processing_instruction {
- struct dom_node_internal base; /**< Base node */
+ dom_node_internal base; /**< Base node */
};
static struct dom_node_vtable pi_vtable = {
+ {
+ DOM_NODE_EVENT_TARGET_VTABLE
+ },
DOM_NODE_VTABLE
};
@@ -39,16 +44,15 @@ static struct dom_node_protect_vtable pi_protect_vtable = {
*
* The returned node will already be referenced.
*/
-dom_exception _dom_processing_instruction_create(struct dom_document *doc,
- struct lwc_string_s *name, dom_string *value,
- struct dom_processing_instruction **result)
+dom_exception _dom_processing_instruction_create(dom_document *doc,
+ dom_string *name, dom_string *value,
+ dom_processing_instruction **result)
{
- struct dom_processing_instruction *p;
+ dom_processing_instruction *p;
dom_exception err;
/* Allocate the comment node */
- p = _dom_document_alloc(doc, NULL,
- sizeof(struct dom_processing_instruction));
+ p = malloc(sizeof(dom_processing_instruction));
if (p == NULL)
return DOM_NO_MEM_ERR;
@@ -60,7 +64,7 @@ dom_exception _dom_processing_instruction_create(struct dom_document *doc,
DOM_PROCESSING_INSTRUCTION_NODE,
name, value, NULL, NULL);
if (err != DOM_NO_ERR) {
- _dom_document_alloc(doc, p, 0);
+ free(p);
return err;
}
@@ -72,19 +76,17 @@ dom_exception _dom_processing_instruction_create(struct dom_document *doc,
/**
* Destroy a processing instruction
*
- * \param doc The owning document
* \param pi The processing instruction to destroy
*
* The contents of ::pi will be destroyed and ::pi will be freed.
*/
-void _dom_processing_instruction_destroy(struct dom_document *doc,
- struct dom_processing_instruction *pi)
+void _dom_processing_instruction_destroy(dom_processing_instruction *pi)
{
/* Finalise base class */
- _dom_processing_instruction_finalise(doc, &pi->base);
+ _dom_processing_instruction_finalise(&pi->base);
/* Free processing instruction */
- _dom_document_alloc(doc, pi, 0);
+ free(pi);
}
/*-----------------------------------------------------------------------*/
@@ -92,34 +94,30 @@ void _dom_processing_instruction_destroy(struct dom_document *doc,
/* Following comes the protected vtable */
/* The virtual destroy function of this class */
-void _dom_pi_destroy(struct dom_node_internal *node)
+void _dom_pi_destroy(dom_node_internal *node)
{
- _dom_processing_instruction_destroy(node->owner,
- (struct dom_processing_instruction *) node);
+ _dom_processing_instruction_destroy(
+ (dom_processing_instruction *) node);
}
-/* The memory allocator of this class */
-dom_exception _dom_pi_alloc(struct dom_document *doc,
- struct dom_node_internal *n, struct dom_node_internal **ret)
+/* The copy constructor of this class */
+dom_exception _dom_pi_copy(dom_node_internal *old, dom_node_internal **copy)
{
- UNUSED(n);
- struct dom_processing_instruction *a;
-
- a = _dom_document_alloc(doc, NULL,
- sizeof(struct dom_processing_instruction));
- if (a == NULL)
+ dom_processing_instruction *new_pi;
+ dom_exception err;
+
+ new_pi = malloc(sizeof(dom_processing_instruction));
+ if (new_pi == NULL)
return DOM_NO_MEM_ERR;
-
- *ret = (dom_node_internal *) a;
- dom_node_set_owner(*ret, doc);
- return DOM_NO_ERR;
-}
+ err = dom_node_copy_internal(old, new_pi);
+ if (err != DOM_NO_ERR) {
+ free(new_pi);
+ return err;
+ }
-/* The copy constructor of this class */
-dom_exception _dom_pi_copy(struct dom_node_internal *new,
- struct dom_node_internal *old)
-{
- return _dom_node_copy(new, old);
+ *copy = (dom_node_internal *) copy;
+
+ return DOM_NO_ERR;
}