summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn-Mark Bell <jmb@netsurf-browser.org>2014-07-18 15:13:43 (GMT)
committer John-Mark Bell <jmb@netsurf-browser.org>2014-07-18 15:13:43 (GMT)
commitd84c6cf52ad8d47d46b4b287d50e81a0bb1dab2e (patch)
tree1ae10e5e19603c65efe1384ee05f88c9583ba614
parent39069dc8b2c570c36a05e3fdaed81fa099dd8cdb (diff)
downloadlibdom-d84c6cf52ad8d47d46b4b287d50e81a0bb1dab2e.tar.gz
libdom-d84c6cf52ad8d47d46b4b287d50e81a0bb1dab2e.tar.bz2
Use the public API as it autoconverts types. Additionally, fix utterly bogus reference counting.
-rw-r--r--src/html/html_tablerow_element.c38
1 files changed, 23 insertions, 15 deletions
diff --git a/src/html/html_tablerow_element.c b/src/html/html_tablerow_element.c
index fb3e27b..75d5cdd 100644
--- a/src/html/html_tablerow_element.c
+++ b/src/html/html_tablerow_element.c
@@ -340,36 +340,44 @@ dom_exception dom_html_table_row_element_insert_cell(
dom_exception dom_html_table_row_element_delete_cell(
dom_html_table_row_element *element,
int32_t index) {
- dom_node *node; /*< The node at the (index)th position*/
-
+ dom_node *node, *old_node; /*< The node at the (index)th position*/
dom_html_collection *cells; /*< The collection of rows in input table_row_element*/
uint32_t len; /*< The size of the row collection */
-
dom_exception exp; /*< Temporary variable to store & check the exceptions*/
exp = dom_html_table_row_element_get_cells(element, &cells);
- if(exp != DOM_NO_ERR) {
+ if (exp != DOM_NO_ERR) {
return exp;
}
exp = dom_html_collection_get_length(cells, &len);
- if(exp != DOM_NO_ERR) {
+ if (exp != DOM_NO_ERR) {
+ dom_html_collection_unref(cells);
return exp;
}
- if(index < -1 || index >= (int32_t)len || len ==0) {
+ if (index < -1 || index >= (int32_t) len || len == 0) {
/* Check for index validity */
+ dom_html_collection_unref(cells);
return DOM_INDEX_SIZE_ERR;
- } else if(index == -1) {
- exp = dom_html_collection_item(cells,
- len-1, &node);
- } else {
- exp = dom_html_collection_item(cells,
- index, &node);
}
- return _dom_node_remove_child((dom_node_internal *)element,
- (dom_node_internal *)node,
- (dom_node_internal **)&node);
+ if (index == -1)
+ index = len - 1;
+
+ exp = dom_html_collection_item(cells, index, &node);
+ if (exp != DOM_NO_ERR) {
+ dom_html_collection_unref(cells);
+ return err;
+ }
+
+ exp = dom_node_remove_child(element, node, &old_node);
+ if (exp == DOM_NO_ERR)
+ dom_node_unref(old_node);
+
+ dom_node_unref(node);
+ dom_html_collection_unref(cells);
+
+ return exp;
}