Skip to content

Commit 07b4885

Browse files
committed
select: No need to NULL guard lwc_string_unref
1 parent eb84151 commit 07b4885

File tree

6 files changed

+41
-88
lines changed

6 files changed

+41
-88
lines changed

src/select/computed.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,8 @@ css_error css_computed_style_destroy(css_computed_style *style)
192192
free(style->quotes);
193193
}
194194

195-
if (style->i.list_style_image != NULL)
196-
lwc_string_unref(style->i.list_style_image);
197-
198-
if (style->i.background_image != NULL)
199-
lwc_string_unref(style->i.background_image);
195+
lwc_string_unref(style->i.list_style_image);
196+
lwc_string_unref(style->i.background_image);
200197

201198
if (style->calc != NULL)
202199
css_calculator_unref(style->calc);

src/select/font_face.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ static void font_faces_srcs_destroy(css_font_face *font_face)
1616
css_font_face_src *srcs = font_face->srcs;
1717

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

2422
free(srcs);
@@ -69,8 +67,7 @@ css_error css__font_face_destroy(css_font_face *font_face)
6967
if (font_face == NULL)
7068
return CSS_BADPARM;
7169

72-
if (font_face->font_family != NULL)
73-
lwc_string_unref(font_face->font_family);
70+
lwc_string_unref(font_face->font_family);
7471

7572
if (font_face->srcs != NULL)
7673
font_faces_srcs_destroy(font_face);
@@ -96,8 +93,7 @@ css_error css__font_face_set_font_family(css_font_face *font_face,
9693
if (font_face == NULL || font_family == NULL)
9794
return CSS_BADPARM;
9895

99-
if (font_face->font_family != NULL)
100-
lwc_string_unref(font_face->font_family);
96+
lwc_string_unref(font_face->font_family);
10197

10298
font_face->font_family = lwc_string_ref(font_family);
10399

src/select/properties/background_image.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ css_error css__set_background_image_from_hint(const css_hint *hint,
2727

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

30-
if (hint->data.string != NULL)
31-
lwc_string_unref(hint->data.string);
30+
lwc_string_unref(hint->data.string);
3231

3332
return error;
3433
}

src/select/properties/list_style_image.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ css_error css__set_list_style_image_from_hint(const css_hint *hint,
2727

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

30-
if (hint->data.string != NULL)
31-
lwc_string_unref(hint->data.string);
30+
lwc_string_unref(hint->data.string);
3231

3332
return error;
3433
}

src/select/select.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,17 +1031,9 @@ static void css_select__finalise_selection_state(
10311031
}
10321032
}
10331033

1034-
if (state->id != NULL) {
1035-
lwc_string_unref(state->id);
1036-
}
1037-
1038-
if (state->element.ns != NULL) {
1039-
lwc_string_unref(state->element.ns);
1040-
}
1041-
1042-
if (state->element.name != NULL){
1043-
lwc_string_unref(state->element.name);
1044-
}
1034+
lwc_string_unref(state->id);
1035+
lwc_string_unref(state->element.ns);
1036+
lwc_string_unref(state->element.name);
10451037

10461038
if (state->revert != NULL) {
10471039
for (size_t i = 0; i < CSS_ORIGIN_AUTHOR; i++) {

src/select/strings.c

Lines changed: 31 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -200,65 +200,35 @@ css_error css_select_strings_intern(css_select_strings *str)
200200

201201
void css_select_strings_unref(css_select_strings *str)
202202
{
203-
if (str->universal != NULL)
204-
lwc_string_unref(str->universal);
205-
if (str->first_child != NULL)
206-
lwc_string_unref(str->first_child);
207-
if (str->link != NULL)
208-
lwc_string_unref(str->link);
209-
if (str->visited != NULL)
210-
lwc_string_unref(str->visited);
211-
if (str->hover != NULL)
212-
lwc_string_unref(str->hover);
213-
if (str->active != NULL)
214-
lwc_string_unref(str->active);
215-
if (str->focus != NULL)
216-
lwc_string_unref(str->focus);
217-
if (str->nth_child != NULL)
218-
lwc_string_unref(str->nth_child);
219-
if (str->nth_last_child != NULL)
220-
lwc_string_unref(str->nth_last_child);
221-
if (str->nth_of_type != NULL)
222-
lwc_string_unref(str->nth_of_type);
223-
if (str->nth_last_of_type != NULL)
224-
lwc_string_unref(str->nth_last_of_type);
225-
if (str->last_child != NULL)
226-
lwc_string_unref(str->last_child);
227-
if (str->first_of_type != NULL)
228-
lwc_string_unref(str->first_of_type);
229-
if (str->last_of_type != NULL)
230-
lwc_string_unref(str->last_of_type);
231-
if (str->only_child != NULL)
232-
lwc_string_unref(str->only_child);
233-
if (str->only_of_type != NULL)
234-
lwc_string_unref(str->only_of_type);
235-
if (str->root != NULL)
236-
lwc_string_unref(str->root);
237-
if (str->empty != NULL)
238-
lwc_string_unref(str->empty);
239-
if (str->target != NULL)
240-
lwc_string_unref(str->target);
241-
if (str->lang != NULL)
242-
lwc_string_unref(str->lang);
243-
if (str->enabled != NULL)
244-
lwc_string_unref(str->enabled);
245-
if (str->disabled != NULL)
246-
lwc_string_unref(str->disabled);
247-
if (str->checked != NULL)
248-
lwc_string_unref(str->checked);
249-
if (str->first_line != NULL)
250-
lwc_string_unref(str->first_line);
251-
if (str->first_letter != NULL)
252-
lwc_string_unref(str->first_letter);
253-
if (str->before != NULL)
254-
lwc_string_unref(str->before);
255-
if (str->after != NULL)
256-
lwc_string_unref(str->after);
257-
258-
if (str->width != NULL)
259-
lwc_string_unref(str->width);
260-
if (str->height != NULL)
261-
lwc_string_unref(str->height);
262-
if (str->prefers_color_scheme != NULL)
263-
lwc_string_unref(str->prefers_color_scheme);
203+
lwc_string_unref(str->universal);
204+
lwc_string_unref(str->first_child);
205+
lwc_string_unref(str->link);
206+
lwc_string_unref(str->visited);
207+
lwc_string_unref(str->hover);
208+
lwc_string_unref(str->active);
209+
lwc_string_unref(str->focus);
210+
lwc_string_unref(str->nth_child);
211+
lwc_string_unref(str->nth_last_child);
212+
lwc_string_unref(str->nth_of_type);
213+
lwc_string_unref(str->nth_last_of_type);
214+
lwc_string_unref(str->last_child);
215+
lwc_string_unref(str->first_of_type);
216+
lwc_string_unref(str->last_of_type);
217+
lwc_string_unref(str->only_child);
218+
lwc_string_unref(str->only_of_type);
219+
lwc_string_unref(str->root);
220+
lwc_string_unref(str->empty);
221+
lwc_string_unref(str->target);
222+
lwc_string_unref(str->lang);
223+
lwc_string_unref(str->enabled);
224+
lwc_string_unref(str->disabled);
225+
lwc_string_unref(str->checked);
226+
lwc_string_unref(str->first_line);
227+
lwc_string_unref(str->first_letter);
228+
lwc_string_unref(str->before);
229+
lwc_string_unref(str->after);
230+
231+
lwc_string_unref(str->width);
232+
lwc_string_unref(str->height);
233+
lwc_string_unref(str->prefers_color_scheme);
264234
}

0 commit comments

Comments
 (0)