diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2009-07-25 15:47:11 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2009-07-25 15:47:11 +0000 |
commit | c51b14383cea9ab41bc53ae27051a969f6dafef3 (patch) | |
tree | e91efe9661d87f7cf490f411406bce05bc8261d2 /css/select.c | |
parent | 2c00c55963d62e8732ad83b878c5d32588e89722 (diff) | |
download | netsurf-c51b14383cea9ab41bc53ae27051a969f6dafef3.tar.gz netsurf-c51b14383cea9ab41bc53ae27051a969f6dafef3.tar.bz2 |
Now that libwapcaplet guarantees NUL-termination of strings, stop copying them unnecessarily.
svn path=/trunk/netsurf/; revision=8785
Diffstat (limited to 'css/select.c')
-rw-r--r-- | css/select.c | 50 |
1 files changed, 5 insertions, 45 deletions
diff --git a/css/select.c b/css/select.c index 0f2f7327e..38c72ae37 100644 --- a/css/select.c +++ b/css/select.c @@ -745,20 +745,10 @@ css_error node_has_attribute(void *pw, void *node, { xmlNode *n = node; xmlAttr *attr; - char *buf; - - buf = malloc(lwc_string_length(name) + 1); - if (buf == NULL) - return CSS_NOMEM; - - memcpy(buf, lwc_string_data(name), lwc_string_length(name)); - buf[lwc_string_length(name)] = '\0'; - - attr = xmlHasProp(n, (const xmlChar *) buf); + + attr = xmlHasProp(n, (const xmlChar *) lwc_string_data(name)); *match = attr != NULL; - free(buf); - return CSS_OK; } @@ -782,18 +772,10 @@ css_error node_has_attribute_equal(void *pw, void *node, { xmlNode *n = node; xmlChar *attr; - char *buf; - - buf = malloc(lwc_string_length(name) + 1); - if (buf == NULL) - return CSS_NOMEM; - - memcpy(buf, lwc_string_data(name), lwc_string_length(name)); - buf[lwc_string_length(name)] = '\0'; *match = false; - attr = xmlGetProp(n, (const xmlChar *) buf); + attr = xmlGetProp(n, (const xmlChar *) lwc_string_data(name)); if (attr != NULL) { *match = strlen((const char *) attr) == lwc_string_length(value) && @@ -803,8 +785,6 @@ css_error node_has_attribute_equal(void *pw, void *node, xmlFree(attr); } - free(buf); - return CSS_OK; } @@ -828,19 +808,11 @@ css_error node_has_attribute_dashmatch(void *pw, void *node, { xmlNode *n = node; xmlChar *attr; - char *buf; size_t vlen = lwc_string_length(value); - buf = malloc(lwc_string_length(name) + 1); - if (buf == NULL) - return CSS_NOMEM; - - memcpy(buf, lwc_string_data(name), lwc_string_length(name)); - buf[lwc_string_length(name)] = '\0'; - *match = false; - attr = xmlGetProp(n, (const xmlChar *) buf); + attr = xmlGetProp(n, (const xmlChar *) lwc_string_data(name)); if (attr != NULL) { const char *p; const char *start = (const char *) attr; @@ -861,8 +833,6 @@ css_error node_has_attribute_dashmatch(void *pw, void *node, } } - free(buf); - return CSS_OK; } @@ -886,19 +856,11 @@ css_error node_has_attribute_includes(void *pw, void *node, { xmlNode *n = node; xmlChar *attr; - char *buf; size_t vlen = lwc_string_length(value); - buf = malloc(lwc_string_length(name) + 1); - if (buf == NULL) - return CSS_NOMEM; - - memcpy(buf, lwc_string_data(name), lwc_string_length(name)); - buf[lwc_string_length(name)] = '\0'; - *match = false; - attr = xmlGetProp(n, (const xmlChar *) buf); + attr = xmlGetProp(n, (const xmlChar *) lwc_string_data(name)); if (attr != NULL) { const char *p; const char *start = (const char *) attr; @@ -919,8 +881,6 @@ css_error node_has_attribute_includes(void *pw, void *node, } } - free(buf); - return CSS_OK; } |