summaryrefslogtreecommitdiff
path: root/bindings
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2012-02-05 23:04:24 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2012-02-05 23:04:24 +0000
commit4044a2de24d1392f8578aa945bdaffaad12ca05e (patch)
treef7e98db6dda9fc11dd0adfd30dcc6705ce13975c /bindings
parent1ab1ed7301d3885a00b3081b3bf7ccdeabd0466a (diff)
downloadlibdom-4044a2de24d1392f8578aa945bdaffaad12ca05e.tar.gz
libdom-4044a2de24d1392f8578aa945bdaffaad12ca05e.tar.bz2
Intern attribute and element names
svn path=/trunk/libdom/; revision=13426
Diffstat (limited to 'bindings')
-rw-r--r--bindings/hubbub/parser.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/bindings/hubbub/parser.c b/bindings/hubbub/parser.c
index 7e64cba..c030e77 100644
--- a/bindings/hubbub/parser.c
+++ b/bindings/hubbub/parser.c
@@ -19,6 +19,7 @@
#include "utils.h"
#include "core/document.h"
+#include "core/string.h"
#include <libwapcaplet/libwapcaplet.h>
@@ -393,19 +394,30 @@ static hubbub_error create_element(void *parser, const hubbub_tag *tag,
{
dom_hubbub_parser *dom_parser = (dom_hubbub_parser *) parser;
dom_exception err;
+ lwc_string *iname;
dom_string *name;
struct dom_element *element = NULL;
hubbub_error herr;
*result = NULL;
- err = dom_string_create(tag->name.ptr, tag->name.len, &name);
+ if (lwc_intern_string((const char *) tag->name.ptr,
+ tag->name.len, &iname) != lwc_error_ok) {
+ dom_parser->msg(DOM_MSG_CRITICAL, dom_parser->mctx,
+ "Can't create element name");
+ goto fail;
+ }
+
+ err = _dom_string_create_from_lwcstring(iname, &name);
if (err != DOM_NO_ERR) {
+ lwc_string_unref(iname);
dom_parser->msg(DOM_MSG_CRITICAL, dom_parser->mctx,
"Can't create element name");
goto fail;
}
+ lwc_string_unref(iname);
+
if (tag->ns == HUBBUB_NS_NULL) {
err = dom_document_create_element(dom_parser->doc, name,
&element);
@@ -695,15 +707,27 @@ static hubbub_error add_attributes(void *parser, void *node,
uint32_t i;
for (i = 0; i < n_attributes; i++) {
+ lwc_string *iname;
dom_string *name, *value;
- err = dom_string_create(attributes[i].name.ptr,
- attributes[i].name.len, &name);
+
+ if (lwc_intern_string((const char *) attributes[i].name.ptr,
+ attributes[i].name.len, &iname) !=
+ lwc_error_ok) {
+ dom_parser->msg(DOM_MSG_CRITICAL, dom_parser->mctx,
+ "Can't create attribute name");
+ goto fail;
+ }
+
+ err = _dom_string_create_from_lwcstring(iname, &name);
if (err != DOM_NO_ERR) {
+ lwc_string_unref(iname);
dom_parser->msg(DOM_MSG_CRITICAL, dom_parser->mctx,
"Can't create attribute name");
goto fail;
}
+ lwc_string_unref(iname);
+
err = dom_string_create(attributes[i].value.ptr,
attributes[i].value.len, &value);
if (err != DOM_NO_ERR) {