diff options
author | Michael Drake <michael.drake@codethink.co.uk> | 2016-02-05 15:56:45 +0000 |
---|---|---|
committer | Michael Drake <michael.drake@codethink.co.uk> | 2016-02-05 15:56:45 +0000 |
commit | 1eb6cc58d7b84a78b9e49abc541ce0495184db59 (patch) | |
tree | 72469ffd5ea7ca86122090be7b960bd09a19cc07 | |
parent | 3542d8d5b0693509a9e2164358326c78c9a5faaa (diff) | |
download | libdom-1eb6cc58d7b84a78b9e49abc541ce0495184db59.tar.gz |
Fix: Proper copy constructor for HTMLBodyElement.
-rw-r--r-- | src/html/html_body_element.c | 35 | ||||
-rw-r--r-- | src/html/html_body_element.h | 9 |
2 files changed, 41 insertions, 3 deletions
diff --git a/src/html/html_body_element.c b/src/html/html_body_element.c index 655fdb0e..0fc4b138 100644 --- a/src/html/html_body_element.c +++ b/src/html/html_body_element.c @@ -107,10 +107,39 @@ void _dom_virtual_html_body_element_destroy(dom_node_internal *node) } /* The virtual copy function, see src/core/node.c for detail */ -dom_exception _dom_html_body_element_copy(dom_node_internal *old, - dom_node_internal **copy) +dom_exception _dom_html_body_element_copy( + dom_node_internal *old, dom_node_internal **copy) { - return _dom_html_element_copy(old, copy); + dom_html_body_element *new_node; + dom_exception err; + + new_node = malloc(sizeof(dom_html_body_element)); + if (new_node == NULL) + return DOM_NO_MEM_ERR; + + err = dom_html_body_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_body_element_copy_internal( + dom_html_body_element *old, + dom_html_body_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_body_element.h b/src/html/html_body_element.h index 765c44da..8b2e0a2b 100644 --- a/src/html/html_body_element.h +++ b/src/html/html_body_element.h @@ -48,5 +48,14 @@ dom_exception _dom_html_body_element_copy(dom_node_internal *old, _dom_virtual_html_body_element_destroy, \ _dom_html_body_element_copy +/* Helper functions*/ +dom_exception _dom_html_body_element_copy_internal( + dom_html_body_element *old, + dom_html_body_element *new); +#define dom_html_body_element_copy_internal(o, n) \ + _dom_html_body_element_copy_internal( \ + (dom_html_body_element *) (o), \ + (dom_html_body_element *) (n)) + #endif |