From daf27a5f11efc1330c2b6ea8a6bb037f9aa7c608 Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Sun, 4 Oct 2020 00:56:17 +0200 Subject: [PATCH] Free output on removal, log add/remove --- main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 753e4e5..8612c68 100644 --- a/main.c +++ b/main.c @@ -172,6 +172,7 @@ static void registry_handle_global(void *data, struct wl_registry *registry, (void)version; struct context *ctx = (struct context *)data; if (strcmp(interface, wl_output_interface.name) == 0) { + fprintf(stderr, "adding output %d\n", name); struct output *output = calloc(1, sizeof(struct output)); output->id = name; output->wl_output = wl_registry_bind(registry, name, @@ -194,13 +195,15 @@ static void registry_handle_global_remove(void *data, struct output *output, *tmp; wl_list_for_each_safe(output, tmp, &ctx->outputs, link) { if (output->id == name) { + fprintf(stderr, "removing output %d\n", name); + wl_list_remove(&output->link); if (output->gamma_control != NULL) { zwlr_gamma_control_v1_destroy(output->gamma_control); } if (output->table_fd != -1) { close(output->table_fd); } - wl_list_remove(&output->link); + free(output); break; } }