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);
|
plistener->setProgress (0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
float** hpmap = new float*[H];
|
float** hpmap = allocArray< float >(W,H, true);
|
||||||
for (int i=0; i<H; i++) {
|
|
||||||
hpmap[i] = new float[W];
|
|
||||||
memset(hpmap[i], 0, W*sizeof(float));
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef _OPENMP
|
#ifdef _OPENMP
|
||||||
#pragma omp parallel
|
#pragma omp parallel
|
||||||
|
@@ -26,21 +26,26 @@
|
|||||||
|
|
||||||
namespace rtengine {
|
namespace rtengine {
|
||||||
|
|
||||||
template<class T> void freeArray (T** a, int H) {
|
// these two functions "simulate" and jagged array, but just use two allocs
|
||||||
//for (int i=0; i<H; i++)
|
template<class T> T** allocArray (int W, int H, bool initZero=false) {
|
||||||
delete [] a[0];
|
|
||||||
delete [] a;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T> T** allocArray (int W, int H) {
|
|
||||||
|
|
||||||
T** t = new T*[H];
|
T** t = new T*[H];
|
||||||
t[0] = new T[H*W];
|
t[0] = new T[H*W];
|
||||||
|
|
||||||
|
if (initZero) memset(t[0],0,sizeof(T)*W*H);
|
||||||
|
|
||||||
for (int i=1; i<H; i++)
|
for (int i=1; i<H; i++)
|
||||||
t[i] = t[i-1]+W;
|
t[i] = t[i-1]+W;
|
||||||
|
|
||||||
return t;
|
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) {
|
template<class T> void freeArray2 (T** a, int H) {
|
||||||
//for (int i=0; i<H; i++)
|
//for (int i=0; i<H; i++)
|
||||||
|
@@ -21,7 +21,7 @@
|
|||||||
#include <glib/gstdio.h>
|
#include <glib/gstdio.h>
|
||||||
#include <safekeyfile.h>
|
#include <safekeyfile.h>
|
||||||
#include <safegtk.h>
|
#include <safegtk.h>
|
||||||
#include <version.h>
|
#include "version.h"
|
||||||
|
|
||||||
CacheImageData::CacheImageData ()
|
CacheImageData::CacheImageData ()
|
||||||
: md5(""), supported(false), format(FT_Invalid), rankOld(-1), inTrashOld(false), recentlySaved(false),
|
: md5(""), supported(false), format(FT_Invalid), rankOld(-1), inTrashOld(false), recentlySaved(false),
|
||||||
|
Reference in New Issue
Block a user