From c51b14383cea9ab41bc53ae27051a969f6dafef3 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sat, 25 Jul 2009 15:47:11 +0000 Subject: Now that libwapcaplet guarantees NUL-termination of strings, stop copying them unnecessarily. svn path=/trunk/netsurf/; revision=8785 --- css/select.c | 50 +++++--------------------------------------------- 1 file changed, 5 insertions(+), 45 deletions(-) (limited to 'css/select.c') 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; } -- cgit v1.2.3