Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions src/parse/language.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,7 @@ css_error css__language_destroy(css_language *language)
if (language == NULL)
return CSS_BADPARM;

if (language->default_namespace != NULL)
lwc_string_unref(language->default_namespace);
lwc_string_unref(language->default_namespace);

if (language->namespaces != NULL) {
for (i = 0; i < language->num_namespaces; i++) {
Expand Down Expand Up @@ -855,8 +854,7 @@ css_error addNamespace(css_language *c, lwc_string *prefix, lwc_string *uri)
{
if (prefix == NULL) {
/* Replace default namespace */
if (c->default_namespace != NULL)
lwc_string_unref(c->default_namespace);
lwc_string_unref(c->default_namespace);

/* Special case: if new namespace uri is "", use NULL */
if (lwc_string_length(uri) == 0)
Expand Down Expand Up @@ -892,8 +890,7 @@ css_error addNamespace(css_language *c, lwc_string *prefix, lwc_string *uri)
}

/* Replace namespace URI */
if (c->namespaces[idx].uri != NULL)
lwc_string_unref(c->namespaces[idx].uri);
lwc_string_unref(c->namespaces[idx].uri);

/* Special case: if new namespace uri is "", use NULL */
if (lwc_string_length(uri) == 0)
Expand Down
6 changes: 2 additions & 4 deletions src/select/autogenerated_propset.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ static inline css_error set_background_image(css_computed_style *style, uint8_t
style->i.background_image = NULL;
}

if (old_string != NULL)
lwc_string_unref(old_string);
lwc_string_unref(old_string);

return CSS_OK;
}
Expand Down Expand Up @@ -1440,8 +1439,7 @@ static inline css_error set_list_style_image(css_computed_style *style, uint8_t
style->i.list_style_image = NULL;
}

if (old_string != NULL)
lwc_string_unref(old_string);
lwc_string_unref(old_string);

return CSS_OK;
}
Expand Down
7 changes: 2 additions & 5 deletions src/select/computed.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,8 @@ css_error css_computed_style_destroy(css_computed_style *style)
free(style->quotes);
}

if (style->i.list_style_image != NULL)
lwc_string_unref(style->i.list_style_image);

if (style->i.background_image != NULL)
lwc_string_unref(style->i.background_image);
lwc_string_unref(style->i.list_style_image);
lwc_string_unref(style->i.background_image);

if (style->calc != NULL)
css_calculator_unref(style->calc);
Expand Down
10 changes: 3 additions & 7 deletions src/select/font_face.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ static void font_faces_srcs_destroy(css_font_face *font_face)
css_font_face_src *srcs = font_face->srcs;

for (i = 0; i < font_face->n_srcs; ++i) {
if (srcs[i].location != NULL) {
lwc_string_unref(srcs[i].location);
}
lwc_string_unref(srcs[i].location);
}

free(srcs);
Expand Down Expand Up @@ -69,8 +67,7 @@ css_error css__font_face_destroy(css_font_face *font_face)
if (font_face == NULL)
return CSS_BADPARM;

if (font_face->font_family != NULL)
lwc_string_unref(font_face->font_family);
lwc_string_unref(font_face->font_family);

if (font_face->srcs != NULL)
font_faces_srcs_destroy(font_face);
Expand All @@ -96,8 +93,7 @@ css_error css__font_face_set_font_family(css_font_face *font_face,
if (font_face == NULL || font_family == NULL)
return CSS_BADPARM;

if (font_face->font_family != NULL)
lwc_string_unref(font_face->font_family);
lwc_string_unref(font_face->font_family);

font_face->font_family = lwc_string_ref(font_family);

Expand Down
3 changes: 1 addition & 2 deletions src/select/properties/background_image.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ css_error css__set_background_image_from_hint(const css_hint *hint,

error = set_background_image(style, hint->status, hint->data.string);

if (hint->data.string != NULL)
lwc_string_unref(hint->data.string);
lwc_string_unref(hint->data.string);

return error;
}
Expand Down
3 changes: 1 addition & 2 deletions src/select/properties/list_style_image.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ css_error css__set_list_style_image_from_hint(const css_hint *hint,

error = set_list_style_image(style, hint->status, hint->data.string);

if (hint->data.string != NULL)
lwc_string_unref(hint->data.string);
lwc_string_unref(hint->data.string);

return error;
}
Expand Down
14 changes: 3 additions & 11 deletions src/select/select.c
Original file line number Diff line number Diff line change
Expand Up @@ -1031,17 +1031,9 @@ static void css_select__finalise_selection_state(
}
}

if (state->id != NULL) {
lwc_string_unref(state->id);
}

if (state->element.ns != NULL) {
lwc_string_unref(state->element.ns);
}

if (state->element.name != NULL){
lwc_string_unref(state->element.name);
}
lwc_string_unref(state->id);
lwc_string_unref(state->element.ns);
lwc_string_unref(state->element.name);

if (state->revert != NULL) {
for (size_t i = 0; i < CSS_ORIGIN_AUTHOR; i++) {
Expand Down
3 changes: 0 additions & 3 deletions src/select/select_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,10 +588,7 @@ def make_propset_h(self):
t.indent(-1)
t.append('}')
t.append()
t.append('if ({} != NULL)'.format(old_n))
t.indent(1)
t.append('lwc_string_unref({});'.format(old_n))
t.indent(-1)

elif v.name == 'string_arr' or v.name == 'counter_arr':
iter_var = 's' if v.name == 'string_arr' else 'c'
Expand Down
92 changes: 31 additions & 61 deletions src/select/strings.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,65 +200,35 @@ css_error css_select_strings_intern(css_select_strings *str)

void css_select_strings_unref(css_select_strings *str)
{
if (str->universal != NULL)
lwc_string_unref(str->universal);
if (str->first_child != NULL)
lwc_string_unref(str->first_child);
if (str->link != NULL)
lwc_string_unref(str->link);
if (str->visited != NULL)
lwc_string_unref(str->visited);
if (str->hover != NULL)
lwc_string_unref(str->hover);
if (str->active != NULL)
lwc_string_unref(str->active);
if (str->focus != NULL)
lwc_string_unref(str->focus);
if (str->nth_child != NULL)
lwc_string_unref(str->nth_child);
if (str->nth_last_child != NULL)
lwc_string_unref(str->nth_last_child);
if (str->nth_of_type != NULL)
lwc_string_unref(str->nth_of_type);
if (str->nth_last_of_type != NULL)
lwc_string_unref(str->nth_last_of_type);
if (str->last_child != NULL)
lwc_string_unref(str->last_child);
if (str->first_of_type != NULL)
lwc_string_unref(str->first_of_type);
if (str->last_of_type != NULL)
lwc_string_unref(str->last_of_type);
if (str->only_child != NULL)
lwc_string_unref(str->only_child);
if (str->only_of_type != NULL)
lwc_string_unref(str->only_of_type);
if (str->root != NULL)
lwc_string_unref(str->root);
if (str->empty != NULL)
lwc_string_unref(str->empty);
if (str->target != NULL)
lwc_string_unref(str->target);
if (str->lang != NULL)
lwc_string_unref(str->lang);
if (str->enabled != NULL)
lwc_string_unref(str->enabled);
if (str->disabled != NULL)
lwc_string_unref(str->disabled);
if (str->checked != NULL)
lwc_string_unref(str->checked);
if (str->first_line != NULL)
lwc_string_unref(str->first_line);
if (str->first_letter != NULL)
lwc_string_unref(str->first_letter);
if (str->before != NULL)
lwc_string_unref(str->before);
if (str->after != NULL)
lwc_string_unref(str->after);

if (str->width != NULL)
lwc_string_unref(str->width);
if (str->height != NULL)
lwc_string_unref(str->height);
if (str->prefers_color_scheme != NULL)
lwc_string_unref(str->prefers_color_scheme);
lwc_string_unref(str->universal);
lwc_string_unref(str->first_child);
lwc_string_unref(str->link);
lwc_string_unref(str->visited);
lwc_string_unref(str->hover);
lwc_string_unref(str->active);
lwc_string_unref(str->focus);
lwc_string_unref(str->nth_child);
lwc_string_unref(str->nth_last_child);
lwc_string_unref(str->nth_of_type);
lwc_string_unref(str->nth_last_of_type);
lwc_string_unref(str->last_child);
lwc_string_unref(str->first_of_type);
lwc_string_unref(str->last_of_type);
lwc_string_unref(str->only_child);
lwc_string_unref(str->only_of_type);
lwc_string_unref(str->root);
lwc_string_unref(str->empty);
lwc_string_unref(str->target);
lwc_string_unref(str->lang);
lwc_string_unref(str->enabled);
lwc_string_unref(str->disabled);
lwc_string_unref(str->checked);
lwc_string_unref(str->first_line);
lwc_string_unref(str->first_letter);
lwc_string_unref(str->before);
lwc_string_unref(str->after);

lwc_string_unref(str->width);
lwc_string_unref(str->height);
lwc_string_unref(str->prefers_color_scheme);
}
9 changes: 3 additions & 6 deletions src/stylesheet.c
Original file line number Diff line number Diff line change
Expand Up @@ -854,8 +854,7 @@ css_error css__stylesheet_selector_destroy(css_stylesheet *sheet,
d = c->combinator;

for (detail = &c->data; detail;) {
if (detail->qname.ns != NULL)
lwc_string_unref(detail->qname.ns);
lwc_string_unref(detail->qname.ns);
lwc_string_unref(detail->qname.name);

if (detail->value_type ==
Expand All @@ -874,8 +873,7 @@ css_error css__stylesheet_selector_destroy(css_stylesheet *sheet,
}

for (detail = &selector->data; detail;) {
if (detail->qname.ns != NULL)
lwc_string_unref(detail->qname.ns);
lwc_string_unref(detail->qname.ns);
lwc_string_unref(detail->qname.name);

if (detail->value_type == CSS_SELECTOR_DETAIL_VALUE_STRING &&
Expand Down Expand Up @@ -1154,8 +1152,7 @@ css_error css__stylesheet_rule_destroy(css_stylesheet *sheet, css_rule *rule)
{
css_rule_import *import = (css_rule_import *) rule;

if (import->url != NULL)
lwc_string_unref(import->url);
lwc_string_unref(import->url);

if (import->media != NULL) {
css__mq_query_destroy(import->media);
Expand Down
Loading