Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NP_TMcode
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Giacomo Mulas
NP_TMcode
Commits
3392d185
Commit
3392d185
authored
Mar 15, 2024
by
Giovanni La Mura
Browse files
Options
Downloads
Patches
Plain Diff
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
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/include/Commons.h
+0
-13
0 additions, 13 deletions
src/include/Commons.h
src/libnptm/Commons.cpp
+5
-16
5 additions, 16 deletions
src/libnptm/Commons.cpp
with
5 additions
and
29 deletions
src/include/Commons.h
+
0
−
13
View file @
3392d185
...
@@ -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
;
...
...
This diff is collapsed.
Click to expand it.
src/libnptm/Commons.cpp
+
5
−
16
View file @
3392d185
...
@@ -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
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment