Fix memleaks

This commit is contained in:
buffet 2020-01-15 20:52:26 +00:00
parent 9ab4ce5652
commit b740e7f2d0
7 changed files with 42 additions and 0 deletions

View file

@ -32,5 +32,6 @@ struct kiwmi_desktop {
};
bool desktop_init(struct kiwmi_desktop *desktop, struct wlr_renderer *renderer);
void desktop_fini(struct kiwmi_desktop *desktop);
#endif /* KIWMI_DESKTOP_DESKTOP_H */

View file

@ -45,5 +45,6 @@ struct kiwmi_cursor_motion_event {
struct kiwmi_cursor *cursor_create(
struct kiwmi_server *server,
struct wlr_output_layout *output_layout);
void cursor_destroy(struct kiwmi_cursor *cursor);
#endif /* KIWMI_INPUT_CURSOR_H */

View file

@ -22,5 +22,6 @@ struct kiwmi_input {
};
bool input_init(struct kiwmi_input *input);
void input_fini(struct kiwmi_input *input);
#endif /* KIWMI_INPUT_INPUT_H */

View file

@ -62,3 +62,9 @@ desktop_init(struct kiwmi_desktop *desktop, struct wlr_renderer *renderer)
return true;
}
void
desktop_fini(struct kiwmi_desktop *desktop)
{
wlr_output_layout_destroy(desktop->output_layout);
}

View file

@ -235,3 +235,19 @@ cursor_create(
return cursor;
}
void
cursor_destroy(struct kiwmi_cursor *cursor)
{
wlr_cursor_destroy(cursor->cursor);
wlr_xcursor_manager_destroy(cursor->xcursor_manager);
wl_list_remove(&cursor->cursor_motion.link);
wl_list_remove(&cursor->cursor_motion_absolute.link);
wl_list_remove(&cursor->cursor_button.link);
wl_list_remove(&cursor->cursor_axis.link);
wl_list_remove(&cursor->cursor_frame.link);
wl_list_remove(&cursor->seat_request_set_cursor.link);
free(cursor);
}

View file

@ -7,6 +7,8 @@
#include "input/input.h"
#include <stdlib.h>
#include <wayland-server.h>
#include <wlr/backend.h>
#include <wlr/types/wlr_cursor.h>
@ -88,3 +90,15 @@ input_init(struct kiwmi_input *input)
return true;
}
void
input_fini(struct kiwmi_input *input)
{
struct kiwmi_keyboard *keyboard;
struct kiwmi_keyboard *tmp;
wl_list_for_each_safe (keyboard, tmp, &input->keyboards, link) {
free(keyboard);
}
cursor_destroy(input->cursor);
}

View file

@ -128,6 +128,9 @@ server_fini(struct kiwmi_server *server)
wl_display_destroy_clients(server->wl_display);
wl_display_destroy(server->wl_display);
desktop_fini(&server->desktop);
input_fini(&server->input);
luaK_destroy(server->lua);
free(server->config_path);