From 265cc14125e4d6126ad1a44683bb2914b70fe6da Mon Sep 17 00:00:00 2001 From: Anders Hafreager Date: Thu, 25 Aug 2016 15:20:12 +0200 Subject: [PATCH] Fixed initialization of arrays in fixes --- src/fix_press_berendsen.cpp | 3 ++- src/fix_print.cpp | 3 ++- src/fix_property_atom.cpp | 3 ++- src/fix_read_restart.cpp | 5 ++--- src/fix_respa.cpp | 3 ++- src/fix_restrain.cpp | 9 +++------ src/fix_setforce.cpp | 3 ++- src/fix_shear_history.cpp | 8 ++------ src/fix_spring.cpp | 3 ++- 9 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/fix_press_berendsen.cpp b/src/fix_press_berendsen.cpp index 58dd0dae92..04e2b3d39c 100644 --- a/src/fix_press_berendsen.cpp +++ b/src/fix_press_berendsen.cpp @@ -37,7 +37,8 @@ enum{ISO,ANISO}; /* ---------------------------------------------------------------------- */ FixPressBerendsen::FixPressBerendsen(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg) + Fix(lmp, narg, arg), + id_temp(NULL), id_press(NULL), tflag(0), pflag(0) { if (narg < 5) error->all(FLERR,"Illegal fix press/berendsen command"); diff --git a/src/fix_print.cpp b/src/fix_print.cpp index 4ed162886d..b553a94e3a 100644 --- a/src/fix_print.cpp +++ b/src/fix_print.cpp @@ -28,7 +28,8 @@ using namespace FixConst; /* ---------------------------------------------------------------------- */ FixPrint::FixPrint(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg) + Fix(lmp, narg, arg), + fp(NULL), string(NULL), copy(NULL), work(NULL) { if (narg < 5) error->all(FLERR,"Illegal fix print command"); nevery = force->inumeric(FLERR,arg[3]); diff --git a/src/fix_property_atom.cpp b/src/fix_property_atom.cpp index 2730390adf..b83aadc95d 100644 --- a/src/fix_property_atom.cpp +++ b/src/fix_property_atom.cpp @@ -29,7 +29,8 @@ enum{MOLECULE,CHARGE,RMASS,INTEGER,DOUBLE}; /* ---------------------------------------------------------------------- */ FixPropertyAtom::FixPropertyAtom(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg) + Fix(lmp, narg, arg), + nvalue(0), style(NULL), index(NULL), astyle(NULL) { if (narg < 4) error->all(FLERR,"Illegal fix property/atom command"); diff --git a/src/fix_read_restart.cpp b/src/fix_read_restart.cpp index 3d49db7196..f174e8160d 100644 --- a/src/fix_read_restart.cpp +++ b/src/fix_read_restart.cpp @@ -23,7 +23,8 @@ using namespace FixConst; /* ---------------------------------------------------------------------- */ FixReadRestart::FixReadRestart(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg) + Fix(lmp, narg, arg), + count(NULL), extra(NULL) { nextra = force->inumeric(FLERR,arg[3]); int nfix = force->inumeric(FLERR,arg[4]); @@ -31,8 +32,6 @@ FixReadRestart::FixReadRestart(LAMMPS *lmp, int narg, char **arg) : // perform initial allocation of atom-based array // register with Atom class - count = NULL; - extra = NULL; grow_arrays(atom->nmax); atom->add_callback(0); diff --git a/src/fix_respa.cpp b/src/fix_respa.cpp index 2902ae8a11..0b6febd7b8 100644 --- a/src/fix_respa.cpp +++ b/src/fix_respa.cpp @@ -24,7 +24,8 @@ using namespace FixConst; /* ---------------------------------------------------------------------- */ FixRespa::FixRespa(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg) + Fix(lmp, narg, arg), + store_torque(0), f_level(NULL), t_level(NULL) { // nlevels = # of rRESPA levels diff --git a/src/fix_restrain.cpp b/src/fix_restrain.cpp index a92352e563..067f1014d5 100644 --- a/src/fix_restrain.cpp +++ b/src/fix_restrain.cpp @@ -44,7 +44,8 @@ enum{BOND,ANGLE,DIHEDRAL}; /* ---------------------------------------------------------------------- */ FixRestrain::FixRestrain(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg) + Fix(lmp, narg, arg), + rstyle(NULL), ids(NULL), kstart(NULL), kstop(NULL), target(NULL), cos_target(NULL), sin_target(NULL) { if (narg < 4) error->all(FLERR,"Illegal fix restrain command"); @@ -57,11 +58,7 @@ FixRestrain::FixRestrain(LAMMPS *lmp, int narg, char **arg) : // parse args nrestrain = maxrestrain = 0; - rstyle = NULL; - ids = NULL; - kstart = kstop = NULL; - target = cos_target = sin_target = NULL; - + int iarg = 3; while (iarg < narg) { if (nrestrain == maxrestrain) { diff --git a/src/fix_setforce.cpp b/src/fix_setforce.cpp index 08f177ae8c..99176bb379 100644 --- a/src/fix_setforce.cpp +++ b/src/fix_setforce.cpp @@ -34,7 +34,8 @@ enum{NONE,CONSTANT,EQUAL,ATOM}; /* ---------------------------------------------------------------------- */ FixSetForce::FixSetForce(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg) + Fix(lmp, narg, arg), + xstr(NULL), ystr(NULL), zstr(NULL), idregion(NULL), sforce(NULL) { if (narg < 6) error->all(FLERR,"Illegal fix setforce command"); diff --git a/src/fix_shear_history.cpp b/src/fix_shear_history.cpp index 7538d57f1a..2577c16be8 100644 --- a/src/fix_shear_history.cpp +++ b/src/fix_shear_history.cpp @@ -34,7 +34,8 @@ enum{NPARTNER,PERPARTNER}; /* ---------------------------------------------------------------------- */ FixShearHistory::FixShearHistory(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg) + Fix(lmp, narg, arg), + npartner(NULL), partner(NULL), shearpartner(NULL), ipage(NULL), dpage(NULL) { if (narg != 4) error->all(FLERR,"Illegal fix SHEAR_HISTORY commmand"); @@ -57,15 +58,10 @@ FixShearHistory::FixShearHistory(LAMMPS *lmp, int narg, char **arg) : // perform initial allocation of atom-based arrays // register with atom class - npartner = NULL; - partner = NULL; - shearpartner = NULL; grow_arrays(atom->nmax); atom->add_callback(0); atom->add_callback(1); - ipage = NULL; - dpage = NULL; pgsize = oneatom = 0; // initialize npartner to 0 so neighbor list creation is OK the 1st time diff --git a/src/fix_spring.cpp b/src/fix_spring.cpp index 5b96e1e95d..fd1db5749f 100644 --- a/src/fix_spring.cpp +++ b/src/fix_spring.cpp @@ -37,7 +37,8 @@ enum{TETHER,COUPLE}; /* ---------------------------------------------------------------------- */ FixSpring::FixSpring(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg) + Fix(lmp, narg, arg), + group2(NULL) { if (narg < 9) error->all(FLERR,"Illegal fix spring command");