summaryrefslogtreecommitdiff
path: root/bindings
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2012-02-22 23:27:27 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2012-02-22 23:27:27 +0000
commit64040fd6999595ba4f89a1edd04e0e6a1e66be1b (patch)
tree1f3a25299213f3eafd8f2e9a98c1df09396f8376 /bindings
parentced06a4b777353086ea61d99cdde4459ef9e9041 (diff)
downloadlibdom-64040fd6999595ba4f89a1edd04e0e6a1e66be1b.tar.gz
libdom-64040fd6999595ba4f89a1edd04e0e6a1e66be1b.tar.bz2
Tidy up a little
svn path=/trunk/libdom/; revision=13461
Diffstat (limited to 'bindings')
-rw-r--r--bindings/hubbub/parser.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/bindings/hubbub/parser.c b/bindings/hubbub/parser.c
index 3774ae7..6dcd60e 100644
--- a/bindings/hubbub/parser.c
+++ b/bindings/hubbub/parser.c
@@ -128,7 +128,7 @@ dom_hubbub_parser *dom_hubbub_parser_create(
hubbub_error error;
dom_exception err;
- parser = dom_hubbub_alloc(NULL, sizeof(dom_hubbub_parser), NULL);
+ parser = malloc(sizeof(dom_hubbub_parser));
if (parser == NULL) {
msg(DOM_MSG_CRITICAL, mctx, "No memory for parsing context");
return NULL;
@@ -147,7 +147,7 @@ dom_hubbub_parser *dom_hubbub_parser_create(
error = hubbub_parser_create(enc, fix_enc, dom_hubbub_alloc, NULL,
&parser->parser);
if (error != HUBBUB_OK) {
- dom_hubbub_alloc(parser, 0, NULL);
+ free(parser);
msg(DOM_MSG_CRITICAL, mctx, "Can't create parser");
return NULL;
}
@@ -160,7 +160,7 @@ dom_hubbub_parser *dom_hubbub_parser_create(
NULL, &parser->doc);
if (err != DOM_NO_ERR) {
hubbub_parser_destroy(parser->parser);
- dom_hubbub_alloc(parser, 0, NULL);
+ free(parser);
msg(DOM_MSG_ERROR, mctx, "Can't create DOM document");
return NULL;
}
@@ -195,7 +195,7 @@ void dom_hubbub_parser_destroy(dom_hubbub_parser *parser)
parser->doc = NULL;
}
- dom_hubbub_alloc(parser, 0, NULL);
+ free(parser);
}
/**
@@ -242,7 +242,8 @@ dom_hubbub_error dom_hubbub_parser_completed(dom_hubbub_parser *parser)
parser->complete = true;
- derr = dom_string_create((const uint8_t *) "id", SLEN("id"), &name);
+ derr = dom_string_create_interned((const uint8_t *) "id", SLEN("id"),
+ &name);
if (derr != DOM_NO_ERR)
return HUBBUB_UNKNOWN;
@@ -425,16 +426,15 @@ static hubbub_error create_element(void *parser, const hubbub_tag *tag,
}
}
- *result = element;
- if (element != NULL) {
- if (tag->n_attributes != 0) {
- herr = add_attributes(parser, element, tag->attributes,
- tag->n_attributes);
- if (herr != HUBBUB_OK)
- return herr;
- }
+ if (element != NULL && tag->n_attributes > 0) {
+ herr = add_attributes(parser, element, tag->attributes,
+ tag->n_attributes);
+ if (herr != HUBBUB_OK)
+ goto clean1;
}
+ *result = element;
+
clean1:
dom_string_unref(name);
@@ -773,7 +773,7 @@ static hubbub_error change_encoding(void *parser, const char *charset)
if (source == HUBBUB_CHARSET_CONFIDENT) {
dom_parser->encoding_source = ENCODING_SOURCE_DETECTED;
- dom_parser->encoding = (char *) charset;
+ dom_parser->encoding = charset;
return HUBBUB_OK;
}