core: factor out freeing struct options members into a function

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2024-02-20 00:18:39 +00:00
parent ac376ad6cb
commit 4954c11aae
No known key found for this signature in database
GPG Key ID: D3A4405BE6CC17F4
3 changed files with 27 additions and 19 deletions

View File

@ -915,4 +915,29 @@ void options_postprocess_c2_lists(struct c2_state *state, struct x_connection *c
}
}
void options_destroy(struct options *options) {
// Free blacklists
c2_list_free(&options->shadow_blacklist, NULL);
c2_list_free(&options->shadow_clip_list, NULL);
c2_list_free(&options->fade_blacklist, NULL);
c2_list_free(&options->focus_blacklist, NULL);
c2_list_free(&options->invert_color_list, NULL);
c2_list_free(&options->blur_background_blacklist, NULL);
c2_list_free(&options->opacity_rules, NULL);
c2_list_free(&options->paint_blacklist, NULL);
c2_list_free(&options->unredir_if_possible_blacklist, NULL);
c2_list_free(&options->rounded_corners_blacklist, NULL);
c2_list_free(&options->corner_radius_rules, NULL);
c2_list_free(&options->window_shader_fg_rules, free);
free(options->write_pid_path);
free(options->logpath);
for (int i = 0; i < options->blur_kernel_count; ++i) {
free(options->blur_kerns[i]);
}
free(options->blur_kerns);
free(options->glx_fshader_win_str);
}
// vim: set noet sw=8 ts=8 :

View File

@ -35,5 +35,6 @@ bool must_use get_cfg(options_t *opt, int argc, char *const *argv, bool shadow_e
win_option_mask_t *winopt_mask);
void options_postprocess_c2_lists(struct c2_state *state, struct x_connection *c,
struct options *option);
void options_destroy(struct options *options);
// vim: set noet sw=8 ts=8:

View File

@ -2625,18 +2625,7 @@ static void session_destroy(session_t *ps) {
list_init_head(&ps->window_stack);
// Free blacklists
c2_list_free(&ps->o.shadow_blacklist, NULL);
c2_list_free(&ps->o.shadow_clip_list, NULL);
c2_list_free(&ps->o.fade_blacklist, NULL);
c2_list_free(&ps->o.focus_blacklist, NULL);
c2_list_free(&ps->o.invert_color_list, NULL);
c2_list_free(&ps->o.blur_background_blacklist, NULL);
c2_list_free(&ps->o.opacity_rules, NULL);
c2_list_free(&ps->o.paint_blacklist, NULL);
c2_list_free(&ps->o.unredir_if_possible_blacklist, NULL);
c2_list_free(&ps->o.rounded_corners_blacklist, NULL);
c2_list_free(&ps->o.corner_radius_rules, NULL);
c2_list_free(&ps->o.window_shader_fg_rules, free);
options_destroy(&ps->o);
c2_state_free(ps->c2_state);
// Free tgt_{buffer,picture} and root_picture
@ -2655,13 +2644,6 @@ static void session_destroy(session_t *ps) {
pixman_region32_fini(&ps->screen_reg);
free(ps->expose_rects);
free(ps->o.write_pid_path);
free(ps->o.logpath);
for (int i = 0; i < ps->o.blur_kernel_count; ++i) {
free(ps->o.blur_kerns[i]);
}
free(ps->o.blur_kerns);
free(ps->o.glx_fshader_win_str);
x_free_monitor_info(&ps->monitors);
render_statistics_destroy(&ps->render_stats);