aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/libgamma-method.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-06-04 00:46:50 +0200
committerMattias Andrée <maandree@operamail.com>2014-06-04 00:46:50 +0200
commitd4e97598c2dd23ffa8d2e14ee6840fe53d925d22 (patch)
treeeee8fead54c7a0746137ad1fa5a69e9d8ebe5f9d /src/lib/libgamma-method.c
parentfix float to integer overflow (diff)
downloadlibgamma-d4e97598c2dd23ffa8d2e14ee6840fe53d925d22.tar.gz
libgamma-d4e97598c2dd23ffa8d2e14ee6840fe53d925d22.tar.bz2
libgamma-d4e97598c2dd23ffa8d2e14ee6840fe53d925d22.tar.xz
fix which ramps are getting calloc
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/lib/libgamma-method.c')
-rw-r--r--src/lib/libgamma-method.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/lib/libgamma-method.c b/src/lib/libgamma-method.c
index f9fa7a3..53a75a0 100644
--- a/src/lib/libgamma-method.c
+++ b/src/lib/libgamma-method.c
@@ -37,7 +37,12 @@
int libgamma_gamma_ramps_initialise(libgamma_gamma_ramps_t* restrict this)
{
size_t n = this->red_size + this->green_size + this->blue_size;
- this->red = malloc(n * sizeof(uint16_t));
+#ifdef HAVE_LIBGAMMA_METHOD_LINUX_DRM
+ /* Valgrind complains about us reading uninitialize memory if we just use malloc. */
+ this->red = calloc(n, sizeof(uint16_t));
+#else
+ this->red = malloc(n * sizeof(uint16_t));
+#endif
this->green = this-> red + this-> red_size;
this->blue = this->green + this->green_size;
return this->red == NULL ? -1 : 0;
@@ -233,12 +238,7 @@ void libgamma_gamma_rampsf_free(libgamma_gamma_rampsf_t* restrict this)
int libgamma_gamma_rampsd_initialise(libgamma_gamma_rampsd_t* restrict this)
{
size_t n = this->red_size + this->green_size + this->blue_size;
-#ifdef HAVE_LIBGAMMA_METHOD_LINUX_DRM
- /* Valgrind complains about us reading uninitialize memory if we just use malloc. */
- this->red = calloc(n, sizeof(double));
-#else
- this->red = malloc(n * sizeof(double));
-#endif
+ this->red = malloc(n * sizeof(double));
this->green = this-> red + this-> red_size;
this->blue = this->green + this->green_size;
return this->red == NULL ? -1 : 0;