summaryrefslogtreecommitdiff
path: root/test/parse.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2008-11-27 12:14:07 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2008-11-27 12:14:07 +0000
commit7adaf92154adc7f3455769ca197f906e3d4cddaa (patch)
treeae172720c8e44a35b87b5506602768db19ec538f /test/parse.c
parent79c0f3bc5c1581a6f2f6568a50e3b4f64b452541 (diff)
downloadlibcss-7adaf92154adc7f3455769ca197f906e3d4cddaa.tar.gz
libcss-7adaf92154adc7f3455769ca197f906e3d4cddaa.tar.bz2
css_string is now the same as a parserutils_dict_entry. This allows us to use dict entries directly as strings.
iChange the way in which selectors are represented. This significantly reduces memory requirements -- reducing the approximate usage count (excludes the string dictionary, which is about 360k) of allzengarden.css from 4,535,400 bytes to 2,414,312 bytes on a 64bit platform. The string dictionary is now created and owned by the stylesheet object. The parser is just given access to this so that it can store strings in it. svn path=/trunk/libcss/; revision=5809
Diffstat (limited to 'test/parse.c')
-rw-r--r--test/parse.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/test/parse.c b/test/parse.c
index 4ff9a6e..33dfe5f 100644
--- a/test/parse.c
+++ b/test/parse.c
@@ -24,11 +24,11 @@ static const char *event_names[] = {
"DECLARATION"
};
-static void *myrealloc(void *ptr, size_t len, void *pw)
+static void *myrealloc(void *data, size_t len, void *pw)
{
UNUSED(pw);
- return realloc(ptr, len);
+ return realloc(data, len);
}
static css_error event_handler(css_parser_event type,
@@ -58,8 +58,8 @@ static css_error event_handler(css_parser_event type,
printf("\n %d", token->type);
- if (token->data.ptr != NULL)
- printf(" %.*s", (int) token->data.len, token->data.ptr);
+ if (token->data.data != NULL)
+ printf(" %.*s", (int) token->data.len, token->data.data);
} while (token != NULL);
printf("\n");
@@ -71,6 +71,7 @@ static css_error event_handler(css_parser_event type,
int main(int argc, char **argv)
{
css_parser_optparams params;
+ parserutils_dict *dict;
css_parser *parser;
FILE *fp;
size_t len, origlen;
@@ -86,7 +87,10 @@ int main(int argc, char **argv)
/* Initialise library */
assert(css_initialise(argv[1], myrealloc, NULL) == CSS_OK);
- assert(css_parser_create("UTF-8", CSS_CHARSET_DICTATED,
+ assert(parserutils_dict_create(myrealloc, NULL, &dict) ==
+ PARSERUTILS_OK);
+
+ assert(css_parser_create("UTF-8", CSS_CHARSET_DICTATED, dict,
myrealloc, NULL, &parser) == CSS_OK);
params.event_handler.handler = event_handler;
@@ -128,6 +132,8 @@ int main(int argc, char **argv)
css_parser_destroy(parser);
+ parserutils_dict_destroy(dict);
+
assert(css_finalise(myrealloc, NULL) == CSS_OK);
printf("PASS\n");