Fixed a (severe) memleak when using HPHD
(Thank Michael for narrowing down to this algo)
This commit is contained in:
@@ -501,11 +501,7 @@ void RawImageSource::hphd_demosaic () {
|
||||
plistener->setProgress (0.0);
|
||||
}
|
||||
|
||||
float** hpmap = new float*[H];
|
||||
for (int i=0; i<H; i++) {
|
||||
hpmap[i] = new float[W];
|
||||
memset(hpmap[i], 0, W*sizeof(float));
|
||||
}
|
||||
float** hpmap = allocArray< float >(W,H, true);
|
||||
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel
|
||||
|
@@ -26,21 +26,26 @@
|
||||
|
||||
namespace rtengine {
|
||||
|
||||
template<class T> void freeArray (T** a, int H) {
|
||||
//for (int i=0; i<H; i++)
|
||||
delete [] a[0];
|
||||
delete [] a;
|
||||
}
|
||||
|
||||
template<class T> T** allocArray (int W, int H) {
|
||||
// these two functions "simulate" and jagged array, but just use two allocs
|
||||
template<class T> T** allocArray (int W, int H, bool initZero=false) {
|
||||
|
||||
T** t = new T*[H];
|
||||
t[0] = new T[H*W];
|
||||
|
||||
if (initZero) memset(t[0],0,sizeof(T)*W*H);
|
||||
|
||||
for (int i=1; i<H; i++)
|
||||
t[i] = t[i-1]+W;
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
template<class T> void freeArray (T** a, int H) {
|
||||
|
||||
delete [] a[0];
|
||||
delete [] a;
|
||||
}
|
||||
|
||||
|
||||
template<class T> void freeArray2 (T** a, int H) {
|
||||
//for (int i=0; i<H; i++)
|
||||
|
Reference in New Issue
Block a user