fixed memory leak in descriptor regression tests
This commit is contained in:
parent
f7d36bbad5
commit
cf0f47f589
@ -60,7 +60,7 @@ static void writeMatInBin( const Mat& mat, const string& filename )
|
|||||||
fwrite( (void*)&mat.rows, sizeof(int), 1, f );
|
fwrite( (void*)&mat.rows, sizeof(int), 1, f );
|
||||||
fwrite( (void*)&mat.cols, sizeof(int), 1, f );
|
fwrite( (void*)&mat.cols, sizeof(int), 1, f );
|
||||||
fwrite( (void*)&type, sizeof(int), 1, f );
|
fwrite( (void*)&type, sizeof(int), 1, f );
|
||||||
int dataSize = (int)(mat.step * mat.rows * mat.channels());
|
int dataSize = (int)(mat.step * mat.rows);
|
||||||
fwrite( (void*)&dataSize, sizeof(int), 1, f );
|
fwrite( (void*)&dataSize, sizeof(int), 1, f );
|
||||||
fwrite( (void*)mat.ptr(), 1, dataSize, f );
|
fwrite( (void*)mat.ptr(), 1, dataSize, f );
|
||||||
fclose(f);
|
fclose(f);
|
||||||
@ -82,13 +82,14 @@ static Mat readMatFromBin( const string& filename )
|
|||||||
int step = dataSize / rows / CV_ELEM_SIZE(type);
|
int step = dataSize / rows / CV_ELEM_SIZE(type);
|
||||||
CV_Assert(step >= cols);
|
CV_Assert(step >= cols);
|
||||||
|
|
||||||
Mat m = Mat(rows, step, type).colRange(0, cols);
|
Mat returnMat = Mat(rows, step, type).colRange(0, cols);
|
||||||
|
|
||||||
size_t elements_read = fread( m.ptr(), 1, dataSize, f );
|
size_t elements_read = fread( returnMat.ptr(), 1, dataSize, f );
|
||||||
CV_Assert(elements_read == (size_t)(dataSize));
|
CV_Assert(elements_read == (size_t)(dataSize));
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
return m;
|
return returnMat;
|
||||||
}
|
}
|
||||||
return Mat();
|
return Mat();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user