Various memory leaks found by valgrind/code review.

Many thanks to Jan for the much neater fast_demo.cc patch.
This commit is contained in:
Steve Herrell
2010-11-10 08:50:54 -05:00
parent 6cce14161f
commit 6d4c50255a
6 changed files with 21 additions and 12 deletions

View File

@@ -25,7 +25,14 @@
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
static float dirwt[0x10000];
static void __attribute__((constructor)) setup_dirwt()
{
//set up directional weight function
for (int i=0; i<0x10000; i++)
dirwt[i] = 1.0/SQR(1.0+i);
}
void RawImageSource::fast_demo(int winx, int winy, int winw, int winh) {
//int winx=0, winy=0;
@@ -43,7 +50,9 @@ void RawImageSource::fast_demo(int winx, int winy, int winw, int winh) {
int clip_pt = 4*65535*ri->defgain;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#pragma omp parallel
{
#pragma omp for
//first, interpolate borders using bilinear
for (int i=0; i<H; i++) {
for (int j=0; j<bord; j++) {//first few columns
@@ -104,7 +113,7 @@ void RawImageSource::fast_demo(int winx, int winy, int winw, int winh) {
}//i
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#pragma omp for
for (int j=bord; j<W-bord; j++) {
for (int i=0; i<bord; i++) {//first few rows
unsigned int sum[6];
@@ -166,14 +175,8 @@ void RawImageSource::fast_demo(int winx, int winy, int winw, int winh) {
if(plistener) plistener->setProgress(0.05);
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
float * dirwt = new float [0x20000];
//set up directional weight function
for (int i=0; i<0x10000; i++)
dirwt[i] = 1.0/SQR(1.0+i);
#pragma omp parallel
{
#pragma omp for
// interpolate G using gradient weights