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-w32gdi.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/gamma-w32gdi.c') diff --git a/src/gamma-w32gdi.c b/src/gamma-w32gdi.c index 9896dce..be39786 100644 --- a/src/gamma-w32gdi.c +++ b/src/gamma-w32gdi.c @@ -41,10 +41,14 @@ static int -w32gdi_init(w32gdi_state_t *state) +w32gdi_init(w32gdi_state_t **state) { - state->saved_ramps = NULL; - state->preserve = 1; + *state = malloc(sizeof(w32gdi_state_t)); + if (state == NULL) return -1; + + w32gdi_state_t *s = *state; + s->saved_ramps = NULL; + s->preserve = 1; return 0; } @@ -96,6 +100,8 @@ w32gdi_free(w32gdi_state_t *state) { /* Free saved ramps */ free(state->saved_ramps); + + free(state); } -- cgit v1.2.3-70-g09d2