summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2017-02-04 14:49:38 (GMT)
committer Michael Drake <tlsa@netsurf-browser.org>2017-02-04 14:49:38 (GMT)
commitb7ab328e53c43560b3a661321e6b57e3ee6d6839 (patch)
tree6a39ca6ed355fa681dbf89479b7a3a6344bff1c3
parent28bebc41e134c972860c6c17a42d69163de56212 (diff)
downloadlibnslayout-b7ab328e53c43560b3a661321e6b57e3ee6d6839.tar.gz
libnslayout-b7ab328e53c43560b3a661321e6b57e3ee6d6839.tar.bz2
util dom-str: Clean up dom strings on failure.
-rw-r--r--src/util/dom-str.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/util/dom-str.c b/src/util/dom-str.c
index 03fdd9e..b1e62a3 100644
--- a/src/util/dom-str.c
+++ b/src/util/dom-str.c
@@ -24,50 +24,50 @@ dom_string *nsl_dom_str_characterdata_modified;
/* Exported function, documented in src/util/dom-str.h */
nslayout_error nsl_dom_str_init(void)
{
+ nslayout_error err;
dom_exception exc;
exc = dom_string_create((const uint8_t *)"DOMNodeInserted",
SLEN("DOMNodeInserted"),
&nsl_dom_str_node_inserted);
if (exc != DOM_NO_ERR) {
- /* TODO: free stuff, return value */
- printf("Failed to create string!\n");
- return NSLAYOUT_NO_MEM;
+ goto out;
}
exc = dom_string_create((const uint8_t *)"DOMNodeRemoved",
SLEN("DOMNodeRemoved"),
&nsl_dom_str_node_removed);
if (exc != DOM_NO_ERR) {
- /* TODO: free stuff, return value */
- printf("Failed to create string!\n");
- return NSLAYOUT_NO_MEM;
+ goto out;
}
exc = dom_string_create((const uint8_t *)"DOMSubtreeModified",
SLEN("DOMSubtreeModified"),
&nsl_dom_str_subtree_modified);
if (exc != DOM_NO_ERR) {
- /* TODO: free stuff, return value */
- printf("Failed to create string!\n");
- return NSLAYOUT_NO_MEM;
+ goto out;
}
exc = dom_string_create((const uint8_t *)"DOMAttrModified",
SLEN("DOMAttrModified"),
&nsl_dom_str_attr_modified);
if (exc != DOM_NO_ERR) {
- /* TODO: free stuff, return value */
- printf("Failed to create string!\n");
- return NSLAYOUT_NO_MEM;
+ goto out;
}
exc = dom_string_create((const uint8_t *)"DOMCharacterDataModified",
SLEN("DOMCharacterDataModified"),
&nsl_dom_str_characterdata_modified);
if (exc != DOM_NO_ERR) {
- /* TODO: free stuff, return value */
- printf("Failed to create string!\n");
- return NSLAYOUT_NO_MEM;
+ goto out;
}
- return NSLAYOUT_OK;
+ err = NSLAYOUT_OK;
+out:
+ if (exc != DOM_NO_ERR) {
+ printf("Failed to initialise dom_str!\n");
+ nsl_dom_str_fini();
+ /* TODO: return value */
+ err = NSLAYOUT_NO_MEM;
+ }
+
+ return err;
}