summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <michael.drake@codethink.co.uk>2016-02-05 17:41:56 (GMT)
committer Michael Drake <michael.drake@codethink.co.uk>2016-02-05 17:41:56 (GMT)
commitcff37d7181675e9cd3256094f98631a24ba2f6c7 (patch)
tree827cd0bd824ac8681bb9a13fce74d97506333f61
parentd82f2377d798f3196dcb98b61ca2d4fd258d2588 (diff)
downloadlibdom-cff37d7181675e9cd3256094f98631a24ba2f6c7.tar.gz
libdom-cff37d7181675e9cd3256094f98631a24ba2f6c7.tar.bz2
Provide generic copy constructor for HTMLSelectElement.
-rw-r--r--src/html/html_select_element.c35
-rw-r--r--src/html/html_select_element.h9
2 files changed, 41 insertions, 3 deletions
diff --git a/src/html/html_select_element.c b/src/html/html_select_element.c
index fe06e5d..c178eb0 100644
--- a/src/html/html_select_element.c
+++ b/src/html/html_select_element.c
@@ -113,10 +113,39 @@ void _dom_virtual_html_select_element_destroy(dom_node_internal *node)
}
/* The virtual copy function, see src/core/node.c for detail */
-dom_exception _dom_html_select_element_copy(dom_node_internal *old,
- dom_node_internal **copy)
+dom_exception _dom_html_select_element_copy(
+ dom_node_internal *old, dom_node_internal **copy)
{
- return _dom_html_element_copy(old, copy);
+ dom_html_select_element *new_node;
+ dom_exception err;
+
+ new_node = malloc(sizeof(dom_html_select_element));
+ if (new_node == NULL)
+ return DOM_NO_MEM_ERR;
+
+ err = dom_html_select_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_select_element_copy_internal(
+ dom_html_select_element *old,
+ dom_html_select_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_select_element.h b/src/html/html_select_element.h
index d7dc0a4..abde182 100644
--- a/src/html/html_select_element.h
+++ b/src/html/html_select_element.h
@@ -58,5 +58,14 @@ dom_exception _dom_html_select_element_copy(dom_node_internal *old,
dom_exception _dom_html_select_element_set_form(
dom_html_select_element *select, dom_html_form_element *form);
+/* Helper functions*/
+dom_exception _dom_html_select_element_copy_internal(
+ dom_html_select_element *old,
+ dom_html_select_element *new);
+#define dom_html_select_element_copy_internal(o, n) \
+ _dom_html_select_element_copy_internal( \
+ (dom_html_select_element *) (o), \
+ (dom_html_select_element *) (n))
+
#endif