Fix memleaks

This commit is contained in:
buffet 2020-01-15 20:52:26 +00:00
parent 724b38df78
commit 352e91258b
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); bool desktop_init(struct kiwmi_desktop *desktop, struct wlr_renderer *renderer);
void desktop_fini(struct kiwmi_desktop *desktop);
#endif /* KIWMI_DESKTOP_DESKTOP_H */ #endif /* KIWMI_DESKTOP_DESKTOP_H */

View file

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

View file

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

View file

@ -62,3 +62,9 @@ desktop_init(struct kiwmi_desktop *desktop, struct wlr_renderer *renderer)
return true; 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; 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 "input/input.h"
#include <stdlib.h>
#include <wayland-server.h> #include <wayland-server.h>
#include <wlr/backend.h> #include <wlr/backend.h>
#include <wlr/types/wlr_cursor.h> #include <wlr/types/wlr_cursor.h>
@ -88,3 +90,15 @@ input_init(struct kiwmi_input *input)
return true; 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_clients(server->wl_display);
wl_display_destroy(server->wl_display); wl_display_destroy(server->wl_display);
desktop_fini(&server->desktop);
input_fini(&server->input);
luaK_destroy(server->lua); luaK_destroy(server->lua);
free(server->config_path); free(server->config_path);