--- ray/src/util/rttree_reduce.c 2016/08/18 00:52:48 2.16 +++ ray/src/util/rttree_reduce.c 2017/05/31 03:26:46 2.17 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rttree_reduce.c,v 2.16 2016/08/18 00:52:48 greg Exp $"; +static const char RCSid[] = "$Id: rttree_reduce.c,v 2.17 2017/05/31 03:26:46 greg Exp $"; #endif /* * A utility called by genBSDF.pl to reduce tensor tree samples and output @@ -223,7 +223,8 @@ read_double(float *rowp, int n) return(0); } if (rblen < n) { - rowbuf = (double *)realloc(rowbuf, sizeof(double)*(rblen=n)); + if (rblen) free(rowbuf); + rowbuf = (double *)malloc(sizeof(double)*(rblen=n)); if (rowbuf == NULL) error(SYSTEM, "out of memory in read_double"); } @@ -283,16 +284,13 @@ load_data(void) int ix, ox; for (ix = 0; ix < 1<<(log2g-1); ix++) for (ox = 0; ox < 1< 0; ox++) + for (oy = 0; oy < siz; oy++) { v1p = &dval4(siz-1-ix,siz-1-iy,ox,oy); v2p = &dval4(siz-1-ox,siz-1-oy,ix,iy); *v1p = *v2p = .5f*( *v1p + *v2p ); + if (--cnt <= 0) + break; } + } } }