summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <michael.drake@codethink.co.uk>2016-02-05 17:47:38 +0000
committerMichael Drake <michael.drake@codethink.co.uk>2016-02-05 17:47:38 +0000
commit609e19e6f68121010f80623835398293d52c9fdc (patch)
tree87595a741378ed209ba8c440b2905131dbcd3995
parent2dda1dd186b9aadebb9464764e799f065af402d6 (diff)
downloadlibdom-609e19e6f68121010f80623835398293d52c9fdc.tar.gz
libdom-609e19e6f68121010f80623835398293d52c9fdc.tar.bz2
Fix: Proper copy constructor for HTMLTableElement.
-rw-r--r--src/html/html_table_element.c35
-rw-r--r--src/html/html_table_element.h9
2 files changed, 41 insertions, 3 deletions
diff --git a/src/html/html_table_element.c b/src/html/html_table_element.c
index 442e1d6..e905f85 100644
--- a/src/html/html_table_element.c
+++ b/src/html/html_table_element.c
@@ -113,10 +113,39 @@ void _dom_virtual_html_table_element_destroy(dom_node_internal *node)
}
/* The virtual copy function, see src/core/node.c for detail */
-dom_exception _dom_html_table_element_copy(dom_node_internal *old,
- dom_node_internal **copy)
+dom_exception _dom_html_table_element_copy(
+ dom_node_internal *old, dom_node_internal **copy)
{
- return _dom_html_element_copy(old, copy);
+ dom_html_table_element *new_node;
+ dom_exception err;
+
+ new_node = malloc(sizeof(dom_html_table_element));
+ if (new_node == NULL)
+ return DOM_NO_MEM_ERR;
+
+ err = dom_html_table_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_table_element_copy_internal(
+ dom_html_table_element *old,
+ dom_html_table_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_table_element.h b/src/html/html_table_element.h
index 4e4747c..4e757cc 100644
--- a/src/html/html_table_element.h
+++ b/src/html/html_table_element.h
@@ -48,6 +48,15 @@ dom_exception _dom_html_table_element_copy(dom_node_internal *old,
_dom_virtual_html_table_element_destroy, \
_dom_html_table_element_copy
+/* Helper functions*/
+dom_exception _dom_html_table_element_copy_internal(
+ dom_html_table_element *old,
+ dom_html_table_element *new);
+#define dom_html_table_element_copy_internal(o, n) \
+ _dom_html_table_element_copy_internal( \
+ (dom_html_table_element *) (o), \
+ (dom_html_table_element *) (n))
+
#endif
bool table_rows_callback(struct dom_node_internal *node, void *ctx);