aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2016-08-05 14:56:14 +0200
committerMattias Andrée <maandree@kth.se>2016-08-05 14:56:14 +0200
commit192c713c9ab0e5597f2f690ebdf777203dcbcbbb (patch)
treece47d3dcefd6e07c2e85eba3706a2c63a5b948b5
parentFix bugs (diff)
downloadcoopgammad-192c713c9ab0e5597f2f690ebdf777203dcbcbbb.tar.gz
coopgammad-192c713c9ab0e5597f2f690ebdf777203dcbcbbb.tar.bz2
coopgammad-192c713c9ab0e5597f2f690ebdf777203dcbcbbb.tar.xz
Fix bugs
Signed-off-by: Mattias Andrée <maandree@kth.se>
-rw-r--r--src/servers/crtc.c4
-rw-r--r--src/servers/gamma.c2
-rw-r--r--src/state.c4
-rw-r--r--src/types/output.c4
4 files changed, 14 insertions, 0 deletions
diff --git a/src/servers/crtc.c b/src/servers/crtc.c
index bc3b51b..9e08820 100644
--- a/src/servers/crtc.c
+++ b/src/servers/crtc.c
@@ -129,6 +129,7 @@ int initialise_crtcs(void)
int gerror;
/* Get partitions */
+ outputs_n = 0;
if (site.partitions_available)
if (!(partitions = calloc(site.partitions_available, sizeof(*partitions))))
goto fail;
@@ -244,12 +245,15 @@ int disconnect(void)
{
outputs[i].crtc = NULL;
libgamma_crtc_destroy(crtcs + i);
+ output_destroy(outputs + i);
}
free(crtcs), crtcs = NULL;
+ free(outputs), outputs = NULL;
for (i = 0; i < site.partitions_available; i++)
libgamma_partition_destroy(partitions + i);
free(partitions), partitions = NULL;
libgamma_site_destroy(&site);
+ memset(&site, 0, sizeof(site));
return 0;
}
diff --git a/src/servers/gamma.c b/src/servers/gamma.c
index 8f2df15..17105d4 100644
--- a/src/servers/gamma.c
+++ b/src/servers/gamma.c
@@ -356,6 +356,8 @@ void restore_gamma(void)
{
if (outputs[i].supported == LIBGAMMA_NO)
continue;
+ if (outputs[i].saved_ramps.u8.red == NULL)
+ continue;
switch (outputs[i].depth)
{
diff --git a/src/state.c b/src/state.c
index d840ccb..71e2146 100644
--- a/src/state.c
+++ b/src/state.c
@@ -298,6 +298,10 @@ size_t state_unmarshal(const void* restrict buf)
outputs_n = *(const size_t*)(bs + off);
off += sizeof(size_t);
+ outputs = calloc(outputs_n, sizeof(*outputs));
+ if (outputs == NULL)
+ return 0;
+
for (i = 0; i < outputs_n; i++)
{
off += n = output_unmarshal(outputs + i, bs + off);
diff --git a/src/types/output.c b/src/types/output.c
index 80f3d36..cc2c52b 100644
--- a/src/types/output.c
+++ b/src/types/output.c
@@ -254,6 +254,10 @@ size_t output_unmarshal(struct output* restrict this, const void* restrict buf)
if (this->name == NULL)
return 0;
+ this->saved_ramps.u8.red_size = this->red_size;
+ this->saved_ramps.u8.green_size = this->green_size;
+ this->saved_ramps.u8.blue_size = this->blue_size;
+
off += n = gamma_ramps_unmarshal(&(this->saved_ramps), bs, this->ramps_size);
COPY_RAMP_SIZES(&(this->saved_ramps.u8), this);
if (n == 0)