Commit 50b9b050 authored by kraus's avatar kraus
Browse files

correctly allocate dynamic memory

parent 63857075
......@@ -733,9 +733,10 @@ FVps<T, N> FVps<T, N>::substitute(const FMatrix<T, N, N> &mat, int nl, int nh) c
// Initialisations.
// Array element fp[k][m] points to the next order m monomial
// to transform in k-th component.
const T *fp[N][nh+1];
const T **fp[N];
T *g[N];
for(int k = N; k-- > 0;) {
fp[k] = new const T* [nh+1];
for(int m = nl; m <= nh; ++m) fp[k][m] = f[k].begin(m);
g[k] = result[k].begin();
}
......@@ -831,6 +832,10 @@ FVps<T, N> FVps<T, N>::substitute(const FMatrix<T, N, N> &mat, int nl, int nh) c
oldvrbl = vrbl;
}
for(int k = N; k-- > 0;) {
delete[] fp[k];
}
return result;
}
......@@ -875,14 +880,16 @@ FVps<T, N> FVps<T, N>::substitute(const FVps<T, N> &rhs, int trunc) const {
if(nl == 0) nl = 1;
// Allocate working arrays.
const T *fp[N][nh+1];
const T ** fp[N];
Array1D< FTps<T, N> > t(nh + 1);
// Initialisations.
// Array element fp[k][m] points to the next order m monomial
// to transform in the k-th component.
for(int k = N; k-- > 0;)
for(int k = N; k-- > 0;) {
fp[k] = new const T* [nh+1];
for(int m = nl; m <= nh; ++m) fp[k][m] = f[k].begin(m);
}
const Array1D<int> *oldvrbl = 0;
int start_nh = FTps<T, N>::orderStart(nh), end_nh = FTps<T, N>::orderEnd(nh);
int nh1 = nh - 1, nh2 = nh - 2;
......@@ -963,6 +970,10 @@ FVps<T, N> FVps<T, N>::substitute(const FVps<T, N> &rhs, int trunc) const {
oldvrbl = vrbl;
}
for(int k = N; k-- > 0;) {
delete[] fp[k];
}
return result;
}
......
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