summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <michael.drake@codethink.co.uk>2016-02-05 17:19:22 (GMT)
committer Michael Drake <michael.drake@codethink.co.uk>2016-02-05 17:19:22 (GMT)
commit5ab752482e77ab60bda0e83de74481bdfeab3a0c (patch)
treedaeb073e56b44e62b2e6fe9850a285d15a096b57
parenta73044080dc6e49838fd770726e2e2f6c0e2eeb9 (diff)
downloadlibdom-5ab752482e77ab60bda0e83de74481bdfeab3a0c.tar.gz
libdom-5ab752482e77ab60bda0e83de74481bdfeab3a0c.tar.bz2
Fix: Proper copy constructor for HTMLModElement.
-rw-r--r--src/html/html_mod_element.c35
-rw-r--r--src/html/html_mod_element.h9
2 files changed, 41 insertions, 3 deletions
diff --git a/src/html/html_mod_element.c b/src/html/html_mod_element.c
index d952a1b..20cb042 100644
--- a/src/html/html_mod_element.c
+++ b/src/html/html_mod_element.c
@@ -110,10 +110,39 @@ void _dom_virtual_html_mod_element_destroy(dom_node_internal *node)
}
/* The virtual copy function, see src/core/node.c for detail */
-dom_exception _dom_html_mod_element_copy(dom_node_internal *old,
- dom_node_internal **copy)
+dom_exception _dom_html_mod_element_copy(
+ dom_node_internal *old, dom_node_internal **copy)
{
- return _dom_html_element_copy(old, copy);
+ dom_html_mod_element *new_node;
+ dom_exception err;
+
+ new_node = malloc(sizeof(dom_html_mod_element));
+ if (new_node == NULL)
+ return DOM_NO_MEM_ERR;
+
+ err = dom_html_mod_element_copy_internal(old, new_node);
+ if (err != DOM_NO_ERR) {
+ free(new_node);
+ return err;
+ }
+
+ *copy = (dom_node_internal *) new_node;
+
+ return DOM_NO_ERR;
+}
+
+dom_exception _dom_html_mod_element_copy_internal(
+ dom_html_mod_element *old,
+ dom_html_mod_element *new)
+{
+ dom_exception err;
+
+ err = dom_html_element_copy_internal(old, new);
+ if (err != DOM_NO_ERR) {
+ return err;
+ }
+
+ return DOM_NO_ERR;
}
/*-----------------------------------------------------------------------*/
diff --git a/src/html/html_mod_element.h b/src/html/html_mod_element.h
index 0e4c49e..c9fbc4c 100644
--- a/src/html/html_mod_element.h
+++ b/src/html/html_mod_element.h
@@ -49,4 +49,13 @@ dom_exception _dom_html_mod_element_copy(dom_node_internal *old,
_dom_virtual_html_mod_element_destroy, \
_dom_html_mod_element_copy
+/* Helper functions*/
+dom_exception _dom_html_mod_element_copy_internal(
+ dom_html_mod_element *old,
+ dom_html_mod_element *new);
+#define dom_html_mod_element_copy_internal(o, n) \
+ _dom_html_mod_element_copy_internal( \
+ (dom_html_mod_element *) (o), \
+ (dom_html_mod_element *) (n))
+
#endif