aboutsummaryrefslogtreecommitdiffstats
path: root/src/gamma-vidmode.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gamma-vidmode.c')
-rw-r--r--src/gamma-vidmode.c21
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