From b27acd687800499324381648036edd098c996524 Mon Sep 17 00:00:00 2001 From: Jon Lund Steffensen Date: Wed, 11 Oct 2017 20:36:41 -0700 Subject: Allocate module data in init functions --- src/gamma-quartz.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/gamma-quartz.c') diff --git a/src/gamma-quartz.c b/src/gamma-quartz.c index 6bacff4..6b7d1ec 100644 --- a/src/gamma-quartz.c +++ b/src/gamma-quartz.c @@ -38,10 +38,14 @@ static int -quartz_init(quartz_state_t *state) +quartz_init(quartz_state_t **state) { - state->preserve = 1; - state->displays = NULL; + *state = malloc(sizeof(quartz_state_t)); + if (*state == NULL) return -1; + + quartz_state_t *s = *state; + s->preserve = 1; + s->displays = NULL; return 0; } @@ -49,7 +53,6 @@ quartz_init(quartz_state_t *state) static int quartz_start(quartz_state_t *state) { - int r; CGError error; uint32_t display_count; @@ -147,6 +150,7 @@ quartz_free(quartz_state_t *state) } } free(state->displays); + free(state); } static void -- cgit v1.2.3-70-g09d2