no if statement required before delete[]
This commit is contained in:
@ -43,7 +43,7 @@ FixDrudeTransform<inverse>::FixDrudeTransform(LAMMPS *lmp, int narg, char **arg)
|
||||
template <bool inverse>
|
||||
FixDrudeTransform<inverse>::~FixDrudeTransform()
|
||||
{
|
||||
if (mcoeff) delete [] mcoeff;
|
||||
delete[] mcoeff;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -65,7 +65,7 @@ FixOneWay::FixOneWay(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg)
|
||||
|
||||
FixOneWay::~FixOneWay()
|
||||
{
|
||||
if (regionstr) delete[] regionstr;
|
||||
delete[] regionstr;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -52,16 +52,16 @@ DihedralSpherical::~DihedralSpherical()
|
||||
memory->destroy(nterms);
|
||||
|
||||
for (int i = 1; i <= atom->ndihedraltypes; i++) {
|
||||
if (Ccoeff[i]) delete[] Ccoeff[i];
|
||||
if (phi_mult[i]) delete[] phi_mult[i];
|
||||
if (phi_shift[i]) delete[] phi_shift[i];
|
||||
if (phi_offset[i]) delete[] phi_offset[i];
|
||||
if (theta1_mult[i]) delete[] theta1_mult[i];
|
||||
if (theta1_shift[i]) delete[] theta1_shift[i];
|
||||
if (theta1_offset[i]) delete[] theta1_offset[i];
|
||||
if (theta2_mult[i]) delete[] theta2_mult[i];
|
||||
if (theta2_shift[i]) delete[] theta2_shift[i];
|
||||
if (theta2_offset[i]) delete[] theta2_offset[i];
|
||||
delete[] Ccoeff[i];
|
||||
delete[] phi_mult[i];
|
||||
delete[] phi_shift[i];
|
||||
delete[] phi_offset[i];
|
||||
delete[] theta1_mult[i];
|
||||
delete[] theta1_shift[i];
|
||||
delete[] theta1_offset[i];
|
||||
delete[] theta2_mult[i];
|
||||
delete[] theta2_shift[i];
|
||||
delete[] theta2_offset[i];
|
||||
}
|
||||
delete[] Ccoeff;
|
||||
delete[] phi_mult;
|
||||
|
||||
@ -44,7 +44,7 @@ NPairSkipIntel::NPairSkipIntel(LAMMPS *lmp) : NPair(lmp) {
|
||||
NPairSkipIntel::~NPairSkipIntel() {
|
||||
delete []_inum_starts;
|
||||
delete []_inum_counts;
|
||||
if (_full_props) delete []_full_props;
|
||||
delete[] _full_props;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -1375,7 +1375,7 @@ void PPPMDisp::init_coeffs()
|
||||
// check if the function should preferably be [1] or [2] or [3]
|
||||
|
||||
if (nsplit == 1) {
|
||||
if (B) delete [] B;
|
||||
delete[] B;
|
||||
function[3] = 0;
|
||||
function[2] = 0;
|
||||
function[1] = 1;
|
||||
@ -1388,12 +1388,12 @@ void PPPMDisp::init_coeffs()
|
||||
utils::logmesg(lmp," Using {} instead of 7 structure factors\n",nsplit);
|
||||
//function[3] = 1;
|
||||
//function[2] = 0;
|
||||
if (B) delete [] B; // remove this when un-comment previous 2 lines
|
||||
delete[] B; // remove this when un-comment previous 2 lines
|
||||
}
|
||||
|
||||
if (function[2] && (nsplit > 6)) {
|
||||
if (me == 0) utils::logmesg(lmp," Using 7 structure factors\n");
|
||||
if (B) delete [] B;
|
||||
delete[] B;
|
||||
}
|
||||
|
||||
if (function[3]) {
|
||||
|
||||
@ -165,8 +165,8 @@ FixNVEManifoldRattle::~FixNVEManifoldRattle()
|
||||
}
|
||||
|
||||
if (tvars ) delete [] tvars;
|
||||
if (tstyle) delete [] tstyle;
|
||||
if (is_var) delete [] is_var;
|
||||
delete[] tstyle;
|
||||
delete[] is_var;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -159,13 +159,13 @@ FixNVTManifoldRattle::FixNVTManifoldRattle(LAMMPS *lmp, int narg, char **arg,
|
||||
FixNVTManifoldRattle::~FixNVTManifoldRattle()
|
||||
{
|
||||
// Deallocate heap-allocated objects.
|
||||
if (eta) delete[] eta;
|
||||
if (eta_dot) delete[] eta_dot;
|
||||
if (eta_dotdot) delete[] eta_dotdot;
|
||||
if (eta_mass) delete[] eta_mass;
|
||||
delete[] eta;
|
||||
delete[] eta_dot;
|
||||
delete[] eta_dotdot;
|
||||
delete[] eta_mass;
|
||||
|
||||
modify->delete_compute(id_temp);
|
||||
if (id_temp) delete[] id_temp;
|
||||
delete[] id_temp;
|
||||
}
|
||||
|
||||
int FixNVTManifoldRattle::setmask()
|
||||
|
||||
@ -321,9 +321,9 @@ void FixPlumed::post_force(int /* vflag */)
|
||||
|
||||
if (nlocal != atom->nlocal) {
|
||||
|
||||
if (charges) delete [] charges;
|
||||
if (masses) delete [] masses;
|
||||
if (gatindex) delete [] gatindex;
|
||||
delete[] charges;
|
||||
delete[] masses;
|
||||
delete[] gatindex;
|
||||
|
||||
nlocal=atom->nlocal;
|
||||
gatindex=new int [nlocal];
|
||||
|
||||
@ -232,7 +232,7 @@ FixReaxFFSpecies::~FixReaxFFSpecies()
|
||||
memory->destroy(MolType);
|
||||
memory->destroy(MolName);
|
||||
|
||||
if (filepos) delete[] filepos;
|
||||
delete[] filepos;
|
||||
|
||||
if (me == 0) {
|
||||
if (compressed)
|
||||
|
||||
@ -615,7 +615,7 @@ void FixPIMD::comm_init()
|
||||
|
||||
if (buf_beads) {
|
||||
for (int i = 0; i < np; i++)
|
||||
if (buf_beads[i]) delete[] buf_beads[i];
|
||||
delete[] buf_beads[i];
|
||||
delete[] buf_beads;
|
||||
}
|
||||
|
||||
|
||||
@ -172,7 +172,7 @@ FixRigidNH::~FixRigidNH()
|
||||
deallocate_order();
|
||||
}
|
||||
|
||||
if (rfix) delete [] rfix;
|
||||
delete[] rfix;
|
||||
|
||||
if (tcomputeflag) modify->delete_compute(id_temp);
|
||||
delete [] id_temp;
|
||||
@ -303,7 +303,7 @@ void FixRigidNH::init()
|
||||
// rfix[] = indices to each fix rigid
|
||||
// this will include self
|
||||
|
||||
if (rfix) delete [] rfix;
|
||||
delete[] rfix;
|
||||
nrigidfix = 0;
|
||||
rfix = nullptr;
|
||||
|
||||
|
||||
@ -184,7 +184,7 @@ FixRigidNHSmall::~FixRigidNHSmall()
|
||||
deallocate_order();
|
||||
}
|
||||
|
||||
if (rfix) delete [] rfix;
|
||||
delete[] rfix;
|
||||
|
||||
if (tcomputeflag) modify->delete_compute(id_temp);
|
||||
delete [] id_temp;
|
||||
@ -301,7 +301,7 @@ void FixRigidNHSmall::init()
|
||||
// rfix[] = indices to each fix rigid
|
||||
// this will include self
|
||||
|
||||
if (rfix) delete [] rfix;
|
||||
delete[] rfix;
|
||||
nrigidfix = 0;
|
||||
rfix = nullptr;
|
||||
|
||||
|
||||
@ -1740,7 +1740,7 @@ int DumpCustom::modify_param(int narg, char **arg)
|
||||
int i = utils::inumeric(FLERR,arg[1],false,lmp) - 1;
|
||||
if (i < 0 || i >= nfield)
|
||||
error->all(FLERR,"Illegal dump_modify command");
|
||||
if (format_column_user[i]) delete[] format_column_user[i];
|
||||
delete[] format_column_user[i];
|
||||
format_column_user[i] = utils::strdup(arg[2]);
|
||||
}
|
||||
return 3;
|
||||
|
||||
@ -257,7 +257,7 @@ int DumpLocal::modify_param(int narg, char **arg)
|
||||
int i = utils::inumeric(FLERR,arg[1],false,lmp) - 1;
|
||||
if (i < 0 || i >= nfield)
|
||||
error->all(FLERR,"Illegal dump_modify command");
|
||||
if (format_column_user[i]) delete[] format_column_user[i];
|
||||
delete[] format_column_user[i];
|
||||
format_column_user[i] = utils::strdup(arg[2]);
|
||||
}
|
||||
return 3;
|
||||
|
||||
@ -41,7 +41,7 @@ DumpXYZ::DumpXYZ(LAMMPS *lmp, int narg, char **arg) : Dump(lmp, narg, arg),
|
||||
sort_flag = 1;
|
||||
sortcol = 0;
|
||||
|
||||
if (format_default) delete [] format_default;
|
||||
delete[] format_default;
|
||||
|
||||
format_default = utils::strdup("%s %g %g %g");
|
||||
|
||||
|
||||
@ -223,7 +223,7 @@ void Force::create_pair(const std::string &style, int trysuffix)
|
||||
{
|
||||
delete[] pair_style;
|
||||
if (pair) delete pair;
|
||||
if (pair_restart) delete[] pair_restart;
|
||||
delete[] pair_restart;
|
||||
pair_style = nullptr;
|
||||
pair = nullptr;
|
||||
pair_restart = nullptr;
|
||||
|
||||
@ -168,7 +168,7 @@ Input::~Input()
|
||||
memory->sfree(line);
|
||||
memory->sfree(copy);
|
||||
memory->sfree(work);
|
||||
if (labelstr) delete[] labelstr;
|
||||
delete[] labelstr;
|
||||
memory->sfree(arg);
|
||||
delete[] infiles;
|
||||
delete variable;
|
||||
@ -1026,7 +1026,7 @@ void Input::jump()
|
||||
|
||||
if (narg == 2) {
|
||||
label_active = 1;
|
||||
if (labelstr) delete[] labelstr;
|
||||
delete[] labelstr;
|
||||
labelstr = utils::strdup(arg[1]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -51,8 +51,8 @@ PairHybrid::~PairHybrid()
|
||||
for (int m = 0; m < nstyles; m++) {
|
||||
delete styles[m];
|
||||
delete[] keywords[m];
|
||||
if (special_lj[m]) delete[] special_lj[m];
|
||||
if (special_coul[m]) delete[] special_coul[m];
|
||||
delete[] special_lj[m];
|
||||
delete[] special_coul[m];
|
||||
}
|
||||
}
|
||||
delete[] styles;
|
||||
@ -275,8 +275,8 @@ void PairHybrid::settings(int narg, char **arg)
|
||||
for (int m = 0; m < nstyles; m++) {
|
||||
delete styles[m];
|
||||
delete[] keywords[m];
|
||||
if (special_lj[m]) delete[] special_lj[m];
|
||||
if (special_coul[m]) delete[] special_coul[m];
|
||||
delete[] special_lj[m];
|
||||
delete[] special_coul[m];
|
||||
}
|
||||
delete[] styles;
|
||||
delete[] keywords;
|
||||
|
||||
@ -250,8 +250,8 @@ void PairHybridScaled::settings(int narg, char **arg)
|
||||
for (int m = 0; m < nstyles; m++) {
|
||||
delete styles[m];
|
||||
delete[] keywords[m];
|
||||
if (special_lj[m]) delete[] special_lj[m];
|
||||
if (special_coul[m]) delete[] special_coul[m];
|
||||
delete[] special_lj[m];
|
||||
delete[] special_coul[m];
|
||||
}
|
||||
delete[] styles;
|
||||
delete[] keywords;
|
||||
|
||||
@ -226,7 +226,7 @@ int main(int narg, char **arg)
|
||||
// extend buffer to fit chunk size
|
||||
|
||||
if (n > maxbuf) {
|
||||
if (buf) delete[] buf;
|
||||
delete[] buf;
|
||||
buf = new double[n];
|
||||
maxbuf = n;
|
||||
}
|
||||
@ -260,6 +260,6 @@ int main(int narg, char **arg)
|
||||
unit_style = nullptr;
|
||||
}
|
||||
|
||||
if (buf) delete[] buf;
|
||||
delete[] buf;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user