Skip to content
Snippets Groups Projects
Commit 3392d185 authored by Giovanni La Mura's avatar Giovanni La Mura
Browse files

Remove C1_AddOns::allocate_vectors() and fix vector memory leak

parent 4f25511e
No related branches found
No related tags found
No related merge requests found
...@@ -208,19 +208,6 @@ protected: ...@@ -208,19 +208,6 @@ protected:
//! \brief Maximum expansion order plus one. QUESTION: correct? //! \brief Maximum expansion order plus one. QUESTION: correct?
int lmpo; int lmpo;
/*! \brief Allocate the necessary common vectors depending on configuration.
*
* The size of the vectors and matrices defined in various common
* blocks, and particularly in C1, depends on many settings of the
* problem configuration, such as the number of spheres, the number
* of layers the spheres are made of, the field expansion order and
* others. This function collects the calculations needed to infer
* the necessary amount of memory for these configurable elements,
* thus making the class constructor more compact and easier to handle.
*
* \param c4: `C4 *` Pointer to a C4 structure.
*/
void allocate_vectors(C4 *c4);
public: public:
//! \brief QUESTION: definition? //! \brief QUESTION: definition?
dcomplex *vh; dcomplex *vh;
......
...@@ -132,6 +132,11 @@ C1_AddOns::C1_AddOns(C4 *c4) { ...@@ -132,6 +132,11 @@ C1_AddOns::C1_AddOns(C4 *c4) {
} }
vintm = new dcomplex[16](); vintm = new dcomplex[16]();
vintt = new dcomplex[16](); vintt = new dcomplex[16]();
// This calculates the size of v3j0
const int nv3j = c4->nv3j;
v3j0 = new double[nv3j]();
ind3j = new int*[lmpo];
for (int ii = 0; ii < lmpo; ii++) ind3j[ii] = new int[c4->lm]();
fsac = new dcomplex*[2]; fsac = new dcomplex*[2];
sac = new dcomplex*[2]; sac = new dcomplex*[2];
fsacm = new dcomplex*[2]; fsacm = new dcomplex*[2];
...@@ -144,7 +149,6 @@ C1_AddOns::C1_AddOns(C4 *c4) { ...@@ -144,7 +149,6 @@ C1_AddOns::C1_AddOns(C4 *c4) {
ecscp = new dcomplex[2](); ecscp = new dcomplex[2]();
scscpm = new dcomplex[2](); scscpm = new dcomplex[2]();
ecscpm = new dcomplex[2](); ecscpm = new dcomplex[2]();
allocate_vectors(c4);
sscs = new double[nsph](); sscs = new double[nsph]();
ecscm = new double[2](); ecscm = new double[2]();
scscm = new double[2](); scscm = new double[2]();
...@@ -185,21 +189,6 @@ C1_AddOns::~C1_AddOns() { ...@@ -185,21 +189,6 @@ C1_AddOns::~C1_AddOns() {
delete[] ecsc; delete[] ecsc;
} }
void C1_AddOns::allocate_vectors(C4 *c4) {
// This calculates the size of v3j0
int lm = (c4->li > c4->le) ? c4->li : c4->le;
const int nv3j = c4->nv3j;
v3j0 = new double[nv3j]();
ind3j = new int*[lmpo];
for (int ii = 0; ii < lmpo; ii++) ind3j[ii] = new int[c4->lm]();
// This calculates the size of vyhj
int ivy = (nsph * nsph - 1) * c4->litpos;
vyhj = new dcomplex[ivy]();
// This calculates the size of vyj0
ivy = c4->lmtpos * c4->nsph;
vyj0 = new dcomplex[ivy]();
}
C2::C2(int ns, int nl, int npnt, int npntts) { C2::C2(int ns, int nl, int npnt, int npntts) {
nsph = ns; nsph = ns;
int max_n = (npnt > npntts) ? npnt : npntts; int max_n = (npnt > npntts) ? npnt : npntts;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment