diff options
author | Michael Drake <michael.drake@codethink.co.uk> | 2016-02-05 17:26:47 +0000 |
---|---|---|
committer | Michael Drake <michael.drake@codethink.co.uk> | 2016-02-05 17:26:47 +0000 |
commit | 89171f671b9c9b4245413b75d2241e59a1d51aed (patch) | |
tree | a030664270c445df1e5c0cbba65dceabbb4aa3c2 /src | |
parent | 64833e7b9ece8b6bfbbd9984e5031da64f8286eb (diff) | |
download | libdom-89171f671b9c9b4245413b75d2241e59a1d51aed.tar.gz libdom-89171f671b9c9b4245413b75d2241e59a1d51aed.tar.bz2 |
Provide generic copy constructor for HTMLOptionElement.
Diffstat (limited to 'src')
-rw-r--r-- | src/html/html_option_element.c | 35 | ||||
-rw-r--r-- | src/html/html_option_element.h | 9 |
2 files changed, 41 insertions, 3 deletions
diff --git a/src/html/html_option_element.c b/src/html/html_option_element.c index a4dec3c..972b7b5 100644 --- a/src/html/html_option_element.c +++ b/src/html/html_option_element.c @@ -445,9 +445,38 @@ void _dom_virtual_html_option_element_destroy(dom_node_internal *node) } /* The virtual copy function, see src/core/node.c for detail */ -dom_exception _dom_html_option_element_copy(dom_node_internal *old, - dom_node_internal **copy) +dom_exception _dom_html_option_element_copy( + dom_node_internal *old, dom_node_internal **copy) { - return _dom_html_element_copy(old, copy); + dom_html_option_element *new_node; + dom_exception err; + + new_node = malloc(sizeof(dom_html_option_element)); + if (new_node == NULL) + return DOM_NO_MEM_ERR; + + err = dom_html_option_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_option_element_copy_internal( + dom_html_option_element *old, + dom_html_option_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_option_element.h b/src/html/html_option_element.h index b1f8b64..4b7d0b1 100644 --- a/src/html/html_option_element.h +++ b/src/html/html_option_element.h @@ -50,5 +50,14 @@ dom_exception _dom_html_option_element_copy(dom_node_internal *old, _dom_virtual_html_option_element_destroy, \ _dom_html_option_element_copy +/* Helper functions*/ +dom_exception _dom_html_option_element_copy_internal( + dom_html_option_element *old, + dom_html_option_element *new); +#define dom_html_option_element_copy_internal(o, n) \ + _dom_html_option_element_copy_internal( \ + (dom_html_option_element *) (o), \ + (dom_html_option_element *) (n)) + #endif |