Fixed a (severe) memleak when using HPHD

(Thank Michael for narrowing down to this algo)
This commit is contained in:
Oliver Duis
2011-05-30 21:54:48 +02:00
parent fc946f45c8
commit 436cfdb750
3 changed files with 14 additions and 13 deletions

View File

@@ -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++)