aboutsummaryrefslogtreecommitdiffstats
path: root/src/gamma-quartz.c
diff options
context:
space:
mode:
authorJon Lund Steffensen <jonlst@gmail.com>2017-10-11 20:36:41 -0700
committerJon Lund Steffensen <jonlst@gmail.com>2017-10-13 18:09:28 -0700
commitb27acd687800499324381648036edd098c996524 (patch)
tree3197172546126fff94e8918ad2244f0788f60ee7 /src/gamma-quartz.c
parentMove module struct definitions to separate files (diff)
downloadredshift-ng-b27acd687800499324381648036edd098c996524.tar.gz
redshift-ng-b27acd687800499324381648036edd098c996524.tar.bz2
redshift-ng-b27acd687800499324381648036edd098c996524.tar.xz
Allocate module data in init functions
Diffstat (limited to 'src/gamma-quartz.c')
-rw-r--r--src/gamma-quartz.c12
1 files changed, 8 insertions, 4 deletions
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