From 041ad8f5ae9d25242a6d39ea8bfc860bc55b0167 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Thu, 6 Oct 2011 19:26:15 +0000 Subject: Extend lifetime of property strings svn path=/trunk/libcss/; revision=12974 --- src/parse/language.c | 10 +--------- src/stylesheet.c | 14 ++++++++++++++ src/stylesheet.h | 1 + 3 files changed, 16 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/parse/language.c b/src/parse/language.c index b3da6b7..0436c22 100644 --- a/src/parse/language.c +++ b/src/parse/language.c @@ -138,13 +138,6 @@ css_error css__language_create(css_stylesheet *sheet, css_parser *parser, return css_error_from_parserutils_error(perror); } - error = css__propstrings_get(&c->strings); - if (error != CSS_OK) { - parserutils_stack_destroy(c->context); - alloc(c, 0, pw); - return error; - } - params.event_handler.handler = language_handle_event; params.event_handler.pw = c; error = css__parser_setopt(parser, CSS_PARSER_EVENT_HANDLER, ¶ms); @@ -159,6 +152,7 @@ css_error css__language_create(css_stylesheet *sheet, css_parser *parser, c->default_namespace = NULL; c->namespaces = NULL; c->num_namespaces = 0; + c->strings = sheet->propstrings; c->alloc = alloc; c->pw = pw; @@ -194,8 +188,6 @@ css_error css__language_destroy(css_language *language) parserutils_stack_destroy(language->context); - css__propstrings_unref(); - language->alloc(language, 0, language->pw); return CSS_OK; diff --git a/src/stylesheet.c b/src/stylesheet.c index ba76d37..f8dedac 100644 --- a/src/stylesheet.c +++ b/src/stylesheet.c @@ -140,6 +140,12 @@ css_error css_stylesheet_create(const css_stylesheet_params *params, return CSS_NOMEM; memset(sheet, 0, sizeof(css_stylesheet)); + + error = css__propstrings_get(&sheet->propstrings); + if (error != CSS_OK) { + alloc(sheet, 0, alloc_pw); + return error; + } sheet->inline_style = params->inline_style; @@ -156,6 +162,7 @@ css_error css_stylesheet_create(const css_stylesheet_params *params, } if (error != CSS_OK) { + css__propstrings_unref(); alloc(sheet, 0, alloc_pw); return error; } @@ -169,6 +176,7 @@ css_error css_stylesheet_create(const css_stylesheet_params *params, &optparams); if (error != CSS_OK) { css__parser_destroy(sheet->parser); + css__propstrings_unref(); alloc(sheet, 0, alloc_pw); return error; } @@ -179,6 +187,7 @@ css_error css_stylesheet_create(const css_stylesheet_params *params, &sheet->parser_frontend); if (error != CSS_OK) { css__parser_destroy(sheet->parser); + css__propstrings_unref(); alloc(sheet, 0, alloc_pw); return error; } @@ -188,6 +197,7 @@ css_error css_stylesheet_create(const css_stylesheet_params *params, if (error != CSS_OK) { css__language_destroy(sheet->parser_frontend); css__parser_destroy(sheet->parser); + css__propstrings_unref(); alloc(sheet, 0, alloc_pw); return error; } @@ -198,6 +208,7 @@ css_error css_stylesheet_create(const css_stylesheet_params *params, css__selector_hash_destroy(sheet->selectors); css__language_destroy(sheet->parser_frontend); css__parser_destroy(sheet->parser); + css__propstrings_unref(); alloc(sheet, 0, alloc_pw); return CSS_NOMEM; } @@ -211,6 +222,7 @@ css_error css_stylesheet_create(const css_stylesheet_params *params, css__selector_hash_destroy(sheet->selectors); css__language_destroy(sheet->parser_frontend); css__parser_destroy(sheet->parser); + css__propstrings_unref(); alloc(sheet, 0, alloc_pw); return CSS_NOMEM; } @@ -293,6 +305,8 @@ css_error css_stylesheet_destroy(css_stylesheet *sheet) if (sheet->string_vector != NULL) sheet->alloc(sheet->string_vector, 0, sheet->pw); + css__propstrings_unref(); + sheet->alloc(sheet, 0, sheet->pw); return CSS_OK; diff --git a/src/stylesheet.h b/src/stylesheet.h index 0dbc487..0f6deed 100644 --- a/src/stylesheet.h +++ b/src/stylesheet.h @@ -182,6 +182,7 @@ struct css_stylesheet { css_language_level level; /**< Language level of sheet */ css_parser *parser; /**< Core parser for sheet */ void *parser_frontend; /**< Frontend parser */ + lwc_string **propstrings; /**< Property strings, for parser */ bool quirks_allowed; /**< Quirks permitted */ bool quirks_used; /**< Quirks actually used */ -- cgit v1.2.3