Fix leaking an array of arrays by freeing it using freeArray2 and introduce a jagged array helper class to use for temporary buffers.

This commit is contained in:
Adam Reichold
2016-02-07 13:04:53 +01:00
parent 706f573f68
commit 7d8fac214a
6 changed files with 100 additions and 145 deletions

View File

@@ -31,37 +31,6 @@
namespace rtengine
{
// 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)
{
delete [] a[0];
}
class RawImageSource : public ImageSource
{