diff options
Diffstat (limited to '')
-rw-r--r-- | src/lib/gamma-helper.c | 7 | ||||
-rw-r--r-- | src/lib/libgamma-method.c | 14 |
2 files changed, 13 insertions, 8 deletions
diff --git a/src/lib/gamma-helper.c b/src/lib/gamma-helper.c index 44e0ff5..470374a 100644 --- a/src/lib/gamma-helper.c +++ b/src/lib/gamma-helper.c @@ -263,7 +263,12 @@ static int allocated_any_ramp(libgamma_gamma_ramps_any_t* restrict ramps_sys, /* Copy the gamma ramp sizes. */ ramps_sys->ANY = ramps.ANY; /* Allocate the new ramps. */ - ramps_sys->ANY.red = malloc(n * d); +#ifdef HAVE_LIBGAMMA_METHOD_LINUX_DRM + /* Valgrind complains about us reading uninitialize memory if we just use malloc. */ + ramps_sys->ANY.red = calloc(n, d); +#else + ramps_sys->ANY.red = malloc(n * d); +#endif ramps_sys->ANY.green = (void*)(((char*)(ramps_sys->ANY. red)) + ramps.ANY. red_size * d / sizeof(char)); ramps_sys->ANY.blue = (void*)(((char*)(ramps_sys->ANY.green)) + ramps.ANY.green_size * d / sizeof(char)); 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; |