mirror of
https://github.com/Cloudef/bemenu
synced 2025-01-03 00:42:02 +00:00
wayland: Free struct window
and struct surf_output
objects
Make sure that we release the memory used by each `wl_list` node that was previously allocated with `calloc`. I'm not sure if freeing the memory of the nodes without removing it from the `wl_list` first could cause any problem so prefer removing it from the list before releasing the memory.
This commit is contained in:
parent
96d206a815
commit
8a79713a34
@ -465,10 +465,11 @@ wl_surface_leave(void *data, struct wl_surface *wl_surface,
|
||||
(void)wl_surface;
|
||||
struct window *window = data;
|
||||
|
||||
struct surf_output *surf_output;
|
||||
wl_list_for_each(surf_output, &window->surf_outputs, link) {
|
||||
struct surf_output *surf_output, *surf_output_tmp;
|
||||
wl_list_for_each_safe(surf_output, surf_output_tmp, &window->surf_outputs, link) {
|
||||
if (surf_output->output->output == wl_output) {
|
||||
wl_list_remove(&surf_output->link);
|
||||
free(surf_output);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -484,11 +485,12 @@ static const struct wl_surface_listener surface_listener = {
|
||||
static void
|
||||
destroy_windows(struct wayland *wayland)
|
||||
{
|
||||
struct window *window;
|
||||
wl_list_for_each(window, &wayland->windows, link) {
|
||||
struct window *window, *window_tmp;
|
||||
wl_list_for_each_safe(window, window_tmp, &wayland->windows, link) {
|
||||
wl_list_remove(&window->link);
|
||||
bm_wl_window_destroy(window);
|
||||
free(window);
|
||||
}
|
||||
wl_list_init(&wayland->windows);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -297,6 +297,12 @@ bm_wl_window_destroy(struct window *window)
|
||||
|
||||
if (window->surface)
|
||||
wl_surface_destroy(window->surface);
|
||||
|
||||
struct surf_output *surf_output, *surf_output_tmp;
|
||||
wl_list_for_each_safe(surf_output, surf_output_tmp, &window->surf_outputs, link) {
|
||||
wl_list_remove(&surf_output->link);
|
||||
free(surf_output);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user