diff options
author | Jon Lund Steffensen <jonlst@gmail.com> | 2017-10-11 20:36:41 -0700 |
---|---|---|
committer | Jon Lund Steffensen <jonlst@gmail.com> | 2017-10-13 18:09:28 -0700 |
commit | b27acd687800499324381648036edd098c996524 (patch) | |
tree | 3197172546126fff94e8918ad2244f0788f60ee7 /src/gamma-vidmode.c | |
parent | Move module struct definitions to separate files (diff) | |
download | redshift-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-vidmode.c')
-rw-r--r-- | src/gamma-vidmode.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/gamma-vidmode.c b/src/gamma-vidmode.c index 8d49363..8d1791a 100644 --- a/src/gamma-vidmode.c +++ b/src/gamma-vidmode.c @@ -38,18 +38,21 @@ static int -vidmode_init(vidmode_state_t *state) +vidmode_init(vidmode_state_t **state) { - state->screen_num = -1; - state->saved_ramps = NULL; + *state = malloc(sizeof(vidmode_state_t)); + if (*state == NULL) return -1; - state->preserve = 1; + vidmode_state_t *s = *state; + s->screen_num = -1; + s->saved_ramps = NULL; + + s->preserve = 1; /* Open display */ - state->display = XOpenDisplay(NULL); - if (state->display == NULL) { - fprintf(stderr, _("X request failed: %s\n"), - "XOpenDisplay"); + s->display = XOpenDisplay(NULL); + if (s->display == NULL) { + fprintf(stderr, _("X request failed: %s\n"), "XOpenDisplay"); return -1; } @@ -121,6 +124,8 @@ vidmode_free(vidmode_state_t *state) /* Close display connection */ XCloseDisplay(state->display); + + free(state); } static void |