plug memory leaks in USER-BOCS
This commit is contained in:
@ -52,6 +52,7 @@ ComputePressureBocs::ComputePressureBocs(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
timeflag = 1;
|
timeflag = 1;
|
||||||
|
|
||||||
p_match_flag = 0;
|
p_match_flag = 0;
|
||||||
|
phi_coeff = NULL;
|
||||||
|
|
||||||
// store temperature ID used by pressure computation
|
// store temperature ID used by pressure computation
|
||||||
// insure it is valid for temperature computation
|
// insure it is valid for temperature computation
|
||||||
@ -119,6 +120,7 @@ ComputePressureBocs::~ComputePressureBocs()
|
|||||||
delete [] id_temp;
|
delete [] id_temp;
|
||||||
delete [] vector;
|
delete [] vector;
|
||||||
delete [] vptr;
|
delete [] vptr;
|
||||||
|
if (phi_coeff) free(phi_coeff);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
@ -263,6 +265,7 @@ void ComputePressureBocs::send_cg_info(int basis_type, int sent_N_basis,
|
|||||||
p_match_flag = 1;
|
p_match_flag = 1;
|
||||||
|
|
||||||
N_basis = sent_N_basis;
|
N_basis = sent_N_basis;
|
||||||
|
if (phi_coeff) free(phi_coeff);
|
||||||
phi_coeff = ((double *) calloc(N_basis, sizeof(double)) );
|
phi_coeff = ((double *) calloc(N_basis, sizeof(double)) );
|
||||||
for (int i=0; i<N_basis; i++) { phi_coeff[i] = sent_phi_coeff[i]; }
|
for (int i=0; i<N_basis; i++) { phi_coeff[i] = sent_phi_coeff[i]; }
|
||||||
|
|
||||||
@ -327,10 +330,10 @@ double ComputePressureBocs::compute_scalar()
|
|||||||
if (keflag)
|
if (keflag)
|
||||||
scalar = (temperature->dof * boltz * t +
|
scalar = (temperature->dof * boltz * t +
|
||||||
virial[0] + virial[1] + virial[2]) / 3.0 *
|
virial[0] + virial[1] + virial[2]) / 3.0 *
|
||||||
inv_volume * nktv2p + (correction); correction
|
inv_volume * nktv2p + (correction);
|
||||||
else
|
else
|
||||||
scalar = (virial[0] + virial[1] + virial[2]) / 3.0 *
|
scalar = (virial[0] + virial[1] + virial[2]) / 3.0 *
|
||||||
inv_volume * nktv2p + (correction); correction
|
inv_volume * nktv2p + (correction);
|
||||||
} else {
|
} else {
|
||||||
if (p_match_flag)
|
if (p_match_flag)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -107,6 +107,8 @@ FixBocs::FixBocs(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
id_temp = NULL;
|
id_temp = NULL;
|
||||||
id_press = NULL;
|
id_press = NULL;
|
||||||
|
|
||||||
|
p_match_coeffs = NULL;
|
||||||
|
|
||||||
// turn on tilt factor scaling, whenever applicable
|
// turn on tilt factor scaling, whenever applicable
|
||||||
|
|
||||||
dimension = domain->dimension;
|
dimension = domain->dimension;
|
||||||
@ -463,6 +465,7 @@ FixBocs::~FixBocs()
|
|||||||
delete [] etap_mass;
|
delete [] etap_mass;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (p_match_coeffs) free(p_match_coeffs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|||||||
Reference in New Issue
Block a user