replace calloc with remaining values emptying

This commit is contained in:
homm 2016-06-08 03:45:08 +03:00
parent c8262660f0
commit 12c8cf94f2

View File

@ -102,10 +102,8 @@ ImagingPrecompute(int inSize, int outSize, struct filter *filterp,
if (outSize > INT_MAX / (2 * sizeof(double)))
return 0;
/* coefficient buffer. kmax elements for each of outSize pixels.
Only xmax number of coefficients are initialized (xmax <= kmax),
other coefficients should be 0, so we are using calloc. */
kk = calloc(outSize * kmax, sizeof(double));
/* coefficient buffer */
kk = malloc(outSize * kmax * sizeof(double));
if ( ! kk)
return 0;
@ -136,6 +134,10 @@ ImagingPrecompute(int inSize, int outSize, struct filter *filterp,
if (ww != 0.0)
k[x] /= ww;
}
// Remaining values should stay empty if they are used despite of xmax.
for (; x < kmax; x++) {
k[x] = 0;
}
xbounds[xx * 2 + 0] = xmin;
xbounds[xx * 2 + 1] = xmax;
}