summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn-Mark Bell <jmb@netsurf-browser.org>2014-07-18 16:01:54 +0100
committerJohn-Mark Bell <jmb@netsurf-browser.org>2014-07-18 16:01:54 +0100
commitc47ab9c5fff7f6eb8567eb7fa776a505f6aaf78f (patch)
tree2a179a13407d114f76b3b2eddbe9d79086054b90 /src
parent70de8cdde8021bccc764865ad7b255241155255f (diff)
downloadlibdom-c47ab9c5fff7f6eb8567eb7fa776a505f6aaf78f.tar.gz
libdom-c47ab9c5fff7f6eb8567eb7fa776a505f6aaf78f.tar.bz2
Use the public API as it autoconverts types. Additionally, fix utterly bogus reference counting.
Diffstat (limited to 'src')
-rw-r--r--src/html/html_tablesection_element.c39
1 files changed, 23 insertions, 16 deletions
diff --git a/src/html/html_tablesection_element.c b/src/html/html_tablesection_element.c
index b35cfb4..af4ccb6 100644
--- a/src/html/html_tablesection_element.c
+++ b/src/html/html_tablesection_element.c
@@ -250,37 +250,44 @@ dom_exception dom_html_table_section_element_insert_row(
dom_exception dom_html_table_section_element_delete_row(
dom_html_table_section_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 *rows; /*< The collection of rows in input table_section_element*/
uint32_t len; /*< The size of the row collection */
-
dom_exception exp; /*< Temporary variable to store & check the exceptions*/
exp = dom_html_table_section_element_get_rows(element, &rows);
- if(exp != DOM_NO_ERR) {
+ if (exp != DOM_NO_ERR) {
return exp;
}
exp = dom_html_collection_get_length(rows, &len);
- if(exp != DOM_NO_ERR) {
+ if (exp != DOM_NO_ERR) {
+ dom_html_collection_unref(rows);
return exp;
}
- if(index < -1 || index >= (int32_t)len) {
+ if (index < -1 || index >= (int32_t) len || (index == -1 && len == 0)) {
/* Check for index validity */
+ dom_html_collection_unref(rows);
return DOM_INDEX_SIZE_ERR;
- } else if(index == -1) {
- exp = dom_html_collection_item(rows,
- len-1, &node);
- } else {
- exp = dom_html_collection_item(rows,
- index, &node);
+ }
+
+ if (index == -1)
+ index = len - 1;
+
+ exp = dom_html_collection_item(rows, index, &node);
+ if (exp != DOM_NO_ERR) {
+ dom_html_collection_unref(rows);
+ return exp;
}
- exp = _dom_node_remove_child((dom_node_internal *)element,
- (dom_node_internal *)node,
- (dom_node_internal **)&node);
- return DOM_NO_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(rows);
+
+ return exp;
}