Free output name, skip storing description

master
Kenny Levinsen 2023-09-01 15:45:46 +02:00
parent aa8015064a
commit b6cfe1761d
1 changed files with 3 additions and 4 deletions

7
main.c
View File

@ -159,7 +159,6 @@ struct output {
uint16_t *table; uint16_t *table;
bool enabled; bool enabled;
char *name; char *name;
char *description;
}; };
static void print_trajectory(struct context *ctx) { static void print_trajectory(struct context *ctx) {
@ -530,11 +529,10 @@ static void wl_output_handle_name(void *data, struct wl_output *wl_output, const
static void wl_output_handle_description(void *data, struct wl_output *wl_output, const char *description) { static void wl_output_handle_description(void *data, struct wl_output *wl_output, const char *description) {
(void)wl_output; (void)wl_output;
struct output *output = data; struct output *output = data;
output->description = strdup(description);
struct config *cfg = &output->context->config; struct config *cfg = &output->context->config;
for (size_t idx = 0; idx < cfg->output_names.len; ++idx) { for (size_t idx = 0; idx < cfg->output_names.len; ++idx) {
if (strcmp(output->description, cfg->output_names.data[idx]) == 0) { if (strcmp(description, cfg->output_names.data[idx]) == 0) {
fprintf(stderr, "enabling output %s by description\n", output->description); fprintf(stderr, "enabling output %s by description\n", description);
output->enabled = true; output->enabled = true;
return; return;
} }
@ -592,6 +590,7 @@ static void registry_handle_global_remove(void *data,
wl_list_for_each_safe(output, tmp, &ctx->outputs, link) { wl_list_for_each_safe(output, tmp, &ctx->outputs, link) {
if (output->id == name) { if (output->id == name) {
fprintf(stderr, "registry: removing output %s (%d)\n", output->name, name); fprintf(stderr, "registry: removing output %s (%d)\n", output->name, name);
free(output->name);
wl_list_remove(&output->link); wl_list_remove(&output->link);
if (output->gamma_control != NULL) { if (output->gamma_control != NULL) {
zwlr_gamma_control_v1_destroy(output->gamma_control); zwlr_gamma_control_v1_destroy(output->gamma_control);