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-drm.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-drm.c')
-rw-r--r-- | src/gamma-drm.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/gamma-drm.c b/src/gamma-drm.c index 19f66fd..e706d46 100644 --- a/src/gamma-drm.c +++ b/src/gamma-drm.c @@ -15,6 +15,7 @@ along with Redshift. If not, see <http://www.gnu.org/licenses/>. Copyright (c) 2014 Mattias Andrée <maandree@member.fsf.org> + Copyright (c) 2017 Jon Lund Steffensen <jonlst@gmail.com> */ #include <stdio.h> @@ -42,14 +43,18 @@ static int -drm_init(drm_state_t *state) +drm_init(drm_state_t **state) { /* Initialize state. */ - state->card_num = 0; - state->crtc_num = -1; - state->fd = -1; - state->res = NULL; - state->crtcs = NULL; + *state = malloc(sizeof(drm_state_t)); + if (*state == NULL) return -1; + + drm_state_t *s = *state; + s->card_num = 0; + s->crtc_num = -1; + s->fd = -1; + s->res = NULL; + s->crtcs = NULL; return 0; } @@ -206,6 +211,8 @@ drm_free(drm_state_t *state) close(state->fd); state->fd = -1; } + + free(state); } static void |