summaryrefslogtreecommitdiff
path: root/source/html/css-apply.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2016-10-12 14:45:23 +0200
committerTor Andersson <tor.andersson@artifex.com>2016-10-12 14:45:42 +0200
commit69c379990d83d83682b23eac3ddf390c0d85e976 (patch)
treec6d2fd66d472784924e524c95552aa41d6c87ce6 /source/html/css-apply.c
parentcf94c2a1e8cac52074183b31f75b71480dbdcea1 (diff)
downloadmupdf-69c379990d83d83682b23eac3ddf390c0d85e976.tar.xz
Use pool allocator when parsing CSS.
Fixes memory leaks when parsing throws exceptions and saves a lot of tiny mallocs for objects that have common life times.
Diffstat (limited to 'source/html/css-apply.c')
-rw-r--r--source/html/css-apply.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/source/html/css-apply.c b/source/html/css-apply.c
index d7375752..03e61a87 100644
--- a/source/html/css-apply.c
+++ b/source/html/css-apply.c
@@ -622,14 +622,14 @@ sort_properties(fz_css_match *match)
}
void
-fz_match_css(fz_context *ctx, fz_css_match *match, fz_css_rule *css, fz_xml *node)
+fz_match_css(fz_context *ctx, fz_css_match *match, fz_css *css, fz_xml *node)
{
fz_css_rule *rule;
fz_css_selector *sel;
fz_css_property *prop, *head, *tail;
const char *s;
- for (rule = css; rule; rule = rule->next)
+ for (rule = css->rule; rule; rule = rule->next)
{
sel = rule->selector;
while (sel)
@@ -649,16 +649,14 @@ fz_match_css(fz_context *ctx, fz_css_match *match, fz_css_rule *css, fz_xml *nod
{
fz_try(ctx)
{
- head = tail = prop = fz_parse_css_properties(ctx, s);
+ head = tail = prop = fz_parse_css_properties(ctx, css->pool, s);
while (prop)
{
add_property(match, prop->name, prop->value, INLINE_SPECIFICITY);
tail = prop;
prop = prop->next;
}
- if (tail)
- tail->next = css->garbage;
- css->garbage = head;
+ /* We can "leak" the property here, since it is freed along with the pool allocator. */
}
fz_catch(ctx)
{
@@ -670,13 +668,13 @@ fz_match_css(fz_context *ctx, fz_css_match *match, fz_css_rule *css, fz_xml *nod
}
void
-fz_match_css_at_page(fz_context *ctx, fz_css_match *match, fz_css_rule *css)
+fz_match_css_at_page(fz_context *ctx, fz_css_match *match, fz_css *css)
{
fz_css_rule *rule;
fz_css_selector *sel;
fz_css_property *prop;
- for (rule = css; rule; rule = rule->next)
+ for (rule = css->rule; rule; rule = rule->next)
{
sel = rule->selector;
while (sel)
@@ -761,12 +759,12 @@ fz_add_css_font_face(fz_context *ctx, fz_html_font_set *set, fz_archive *zip, co
}
void
-fz_add_css_font_faces(fz_context *ctx, fz_html_font_set *set, fz_archive *zip, const char *base_uri, fz_css_rule *css)
+fz_add_css_font_faces(fz_context *ctx, fz_html_font_set *set, fz_archive *zip, const char *base_uri, fz_css *css)
{
fz_css_rule *rule;
fz_css_selector *sel;
- for (rule = css; rule; rule = rule->next)
+ for (rule = css->rule; rule; rule = rule->next)
{
sel = rule->selector;
while (sel)