diff --git a/config.c b/config.c index f7452994..b4518622 100644 --- a/config.c +++ b/config.c @@ -2379,9 +2379,10 @@ config_load(struct config *conf, const char *conf_path, conf->url_launch.raw_cmd = xstrdup("xdg-open ${url}"); tokenize_cmdline(conf->url_launch.raw_cmd, &conf->url_launch.argv); - tll_foreach(*initial_user_notifications, it) + tll_foreach(*initial_user_notifications, it) { tll_push_back(conf->notifications, it->item); - tll_free(*initial_user_notifications); + tll_remove(*initial_user_notifications, it); + } add_default_key_bindings(conf); add_default_search_bindings(conf); @@ -2462,9 +2463,10 @@ config_free(struct config conf) free_spawn_template(&conf.notify); free_spawn_template(&conf.url_launch); for (size_t i = 0; i < ALEN(conf.fonts); i++) { - tll_foreach(conf.fonts[i], it) + tll_foreach(conf.fonts[i], it) { config_font_destroy(&it->item); - tll_free(conf.fonts[i]); + tll_remove(conf.fonts[i], it); + } } free(conf.server_socket_path); diff --git a/terminal.c b/terminal.c index 91a442ec..8e1e1841 100644 --- a/terminal.c +++ b/terminal.c @@ -1474,20 +1474,25 @@ term_destroy(struct terminal *term) xassert(tll_length(term->render.workers.queue) == 0); tll_free(term->render.workers.queue); - tll_foreach(term->ptmx_buffers, it) - free(it->item.data); - tll_free(term->ptmx_buffers); - tll_foreach(term->ptmx_paste_buffers, it) - free(it->item.data); - tll_free(term->ptmx_paste_buffers); tll_free(term->tab_stops); - tll_foreach(term->normal.sixel_images, it) + tll_foreach(term->ptmx_buffers, it) { + free(it->item.data); + tll_remove(term->ptmx_buffers, it); + } + tll_foreach(term->ptmx_paste_buffers, it) { + free(it->item.data); + tll_remove(term->ptmx_paste_buffers, it); + } + + tll_foreach(term->normal.sixel_images, it) { sixel_destroy(&it->item); - tll_free(term->normal.sixel_images); - tll_foreach(term->alt.sixel_images, it) + tll_remove(term->normal.sixel_images, it); + } + tll_foreach(term->alt.sixel_images, it) { sixel_destroy(&it->item); - tll_free(term->alt.sixel_images); + tll_remove(term->alt.sixel_images, it); + } sixel_fini(term); urls_reset(term); @@ -1642,12 +1647,14 @@ term_reset(struct terminal *term, bool hard) term->meta.esc_prefix = true; term->meta.eight_bit = true; - tll_foreach(term->normal.sixel_images, it) + tll_foreach(term->normal.sixel_images, it) { sixel_destroy(&it->item); - tll_free(term->normal.sixel_images); - tll_foreach(term->alt.sixel_images, it) + tll_remove(term->normal.sixel_images, it); + } + tll_foreach(term->alt.sixel_images, it) { sixel_destroy(&it->item); - tll_free(term->alt.sixel_images); + tll_remove(term->alt.sixel_images, it); + } #if defined(FOOT_IME_ENABLED) && FOOT_IME_ENABLED term_ime_enable(term); diff --git a/url-mode.c b/url-mode.c index 40f3372f..df870677 100644 --- a/url-mode.c +++ b/url-mode.c @@ -540,15 +540,15 @@ urls_reset(struct terminal *term) wl_subsurface_destroy(it->item.sub_surf); if (it->item.surf != NULL) wl_surface_destroy(it->item.surf); + tll_remove(term->window->urls, it); } - tll_free(term->window->urls); } tll_foreach(term->urls, it) { tag_cells_for_url(term, &it->item, false); url_destroy(&it->item); + tll_remove(term->urls, it); } - tll_free(term->urls); memset(term->url_keys, 0, sizeof(term->url_keys)); render_refresh(term); diff --git a/wayland.c b/wayland.c index 2a79bb10..255adf1f 100644 --- a/wayland.c +++ b/wayland.c @@ -1240,13 +1240,15 @@ wayl_destroy(struct wayland *wayl) fdm_hook_del(wayl->fdm, &fdm_hook, FDM_HOOK_PRIORITY_LOW); - tll_foreach(wayl->monitors, it) + tll_foreach(wayl->monitors, it) { monitor_destroy(&it->item); - tll_free(wayl->monitors); + tll_remove(wayl->monitors, it); + } - tll_foreach(wayl->seats, it) + tll_foreach(wayl->seats, it) { seat_destroy(&it->item); - tll_free(wayl->seats); + tll_remove(wayl->seats, it); + } #if defined(FOOT_IME_ENABLED) && FOOT_IME_ENABLED if (wayl->text_input_manager != NULL) @@ -1431,8 +1433,8 @@ wayl_win_destroy(struct wl_window *win) wl_subsurface_destroy(it->item.sub_surf); if (it->item.surf != NULL) wl_surface_destroy(it->item.surf); + tll_remove(win->urls, it); } - tll_free(win->urls); csd_destroy(win); if (win->render_timer_sub_surface != NULL)