diff --git a/src/USER-BOCS/compute_pressure_bocs.cpp b/src/USER-BOCS/compute_pressure_bocs.cpp index 24d9e7bf11..4ac0a1a049 100644 --- a/src/USER-BOCS/compute_pressure_bocs.cpp +++ b/src/USER-BOCS/compute_pressure_bocs.cpp @@ -115,6 +115,7 @@ ComputePressureBocs::ComputePressureBocs(LAMMPS *lmp, int narg, char **arg) : vector = new double[size_vector]; nvirial = 0; vptr = NULL; + splines = NULL; spline_length = 0; } @@ -127,10 +128,6 @@ ComputePressureBocs::~ComputePressureBocs() delete [] vector; delete [] vptr; if (phi_coeff) free(phi_coeff); - - // Any splines data that was sent in from fix_bocs must be - // freed here, after it has been used. - memory->destroy(splines); } /* ---------------------------------------------------------------------- */ diff --git a/src/USER-BOCS/fix_bocs.cpp b/src/USER-BOCS/fix_bocs.cpp index 7deba9bacb..97ad6d9f04 100644 --- a/src/USER-BOCS/fix_bocs.cpp +++ b/src/USER-BOCS/fix_bocs.cpp @@ -118,6 +118,9 @@ FixBocs::FixBocs(LAMMPS *lmp, int narg, char **arg) : p_match_coeffs = NULL; + splines = NULL; + spline_length = 0; + // turn on tilt factor scaling, whenever applicable dimension = domain->dimension; @@ -476,6 +479,12 @@ FixBocs::~FixBocs() } } if (p_match_coeffs) free(p_match_coeffs); + + // Free splines memory structure + if (splines != NULL) { + memory->destroy(splines); + spline_length = 0; + } } /* ---------------------------------------------------------------------- */