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

Clean memory after execution of dme()

parent 2a0a5f14
No related branches found
No related tags found
No related merge requests found
/*! \file sph_subs.h
*
* \brief C++ porting of SPH functions, subroutines and data structures.
* \brief C++ porting of SPH functions and subroutines.
*
* Remember that FORTRAN passes arguments by reference, so, every time we use
* a subroutine call, we need to add a referencing layer to the C++ variable.
......@@ -11,11 +11,14 @@
* types are given, to avoid doxygen warning messages.
*/
#ifndef SRC_INCLUDE_SPH_SUBS_H_
#define SRC_INCLUDE_SPH_SUBS_H_
#ifndef INCLUDE_COMMONS_H_
#include "Commons.h"
#endif
#ifndef INCLUDE_SPH_SUBS_H_
#define INCLUDE_SPH_SUBS_H_
#include <complex>
#include "Commons.h"
/*! \brief Conjugate of a double precision complex number
*
......@@ -1346,7 +1349,6 @@ void wmasp(
void dme(
int li, int i, int npnt, int npntts, double vk, double exdc, double exri,
C1 *c1, C2 *c2, int &jer, int &lcalc, std::complex<double> &arg) {
//double rfj[42], rfn[42];
double *rfj = new double[42];
double *rfn = new double[42];
std::complex<double> cfj[42], fbi[42], fb[42], fn[42];
......@@ -1371,6 +1373,8 @@ void dme(
cbf(lipo, arg, lcalc, cfj);
if (lcalc < lipo) {
jer = 5;
delete[] rfj;
delete[] rfn;
return;
}
for (int j24 = 1; j24 <= lipt; j24++) fbi[j24 - 1] = cfj[j24 - 1];
......@@ -1380,6 +1384,8 @@ void dme(
rbf(lipo, arg.real(), lcalc, rfj);
if (lcalc < lipo) {
jer = 5;
delete[] rfj;
delete[] rfn;
return;
}
for (int j30 = 1; j30 <= lipt; j30++) fbi[j30 - 1] = rfj[j30 - 1];
......@@ -1389,11 +1395,15 @@ void dme(
rbf(lipo, arex, lcalc, rfj);
if (lcalc < lipo) {
jer = 7;
delete[] rfj;
delete[] rfn;
return;
}
rnf(lipo, arex, lcalc, rfn);
if (lcalc < lipo) {
jer = 8;
delete[] rfj;
delete[] rfn;
return;
}
for (int j43 = 1; j43 <= lipt; j43++) {
......@@ -1473,6 +1483,8 @@ void dme(
//printf("DEBUG: gone 90, rei[%d][%d] = (%lE,%lE)\n", l90, i, c1->rei[l90 - 1][i - 1].real(), c1->rei[l90 - 1][i - 1].imag());
}
} // nsh <= 1 ?
delete[] rfj;
delete[] rfn;
return;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment