Commit cf0f47f5 authored by Ilya Lavrenov's avatar Ilya Lavrenov Committed by Dikay900

fixed memory leak in descriptor regression tests

parent f7d36bba
...@@ -60,7 +60,7 @@ static void writeMatInBin( const Mat& mat, const string& filename ) ...@@ -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 ) ...@@ -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();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment