Add free functions for allocated resources

This commit is contained in:
Drew DeVault 2017-04-25 21:26:29 -04:00
parent 1e8970b4a9
commit 1aed987301
10 changed files with 96 additions and 10 deletions

14
wayland/CMakeLists.txt Normal file
View file

@ -0,0 +1,14 @@
include_directories(
${PROTOCOLS_INCLUDE_DIRS}
${WAYLAND_INCLUDE_DIR}
)
add_library(wlr-wayland
types/wlr_wl_seat.c
types/wlr_wl_output.c
)
target_link_libraries(wlr-wayland
wlr-common
${WAYLAND_LIBRARIES}
)

View file

@ -0,0 +1,16 @@
#include <stdlib.h>
#include <wayland-client.h>
#include "wlr/wayland.h"
#include "wlr/common/list.h"
void wlr_wl_output_free(struct wlr_wl_output *output) {
if (!output) return;
if (output->wl_output) wl_output_destroy(output->wl_output);
if (output->make) free(output->make);
if (output->model) free(output->model);
for (size_t i = 0; output->modes && i < output->modes->length; ++i) {
free(output->modes->items[i]);
}
list_free(output->modes);
free(output);
}

View file

@ -0,0 +1,19 @@
#include <stdlib.h>
#include <wayland-client.h>
#include "wlr/wayland.h"
#include "wlr/common/list.h"
void wlr_wl_seat_free(struct wlr_wl_seat *seat) {
if (!seat) return;
if (seat->wl_seat) wl_seat_destroy(seat->wl_seat);
if (seat->name) free(seat->name);
if (seat->keyboards) {
// TODO: free children
list_free(seat->keyboards);
}
if (seat->pointers) {
// TODO: free children
list_free(seat->keyboards);
}
free(seat);
}