From db077ef186c2cc651f3337fd3f1f58171a5ed7d8 Mon Sep 17 00:00:00 2001 From: Anders Hafreager Date: Thu, 25 Aug 2016 10:33:33 +0200 Subject: [PATCH] Fixed initialization of arrays in fixes --- src/fix.cpp | 5 ++--- src/fix_adapt.cpp | 5 ++--- src/fix_addforce.cpp | 6 +++--- src/fix_ave_atom.cpp | 4 ++-- src/fix_ave_correlate.cpp | 4 +++- src/fix_ave_histo.cpp | 4 +++- src/fix_ave_time.cpp | 5 ++++- src/fix_aveforce.cpp | 3 ++- 8 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/fix.cpp b/src/fix.cpp index c83385228c..aa18e04762 100644 --- a/src/fix.cpp +++ b/src/fix.cpp @@ -31,7 +31,8 @@ int Fix::instance_total = 0; /* ---------------------------------------------------------------------- */ -Fix::Fix(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) +Fix::Fix(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp), +id(NULL), style(NULL), eatom(NULL), vatom(NULL) { instance_me = instance_total++; @@ -92,8 +93,6 @@ Fix::Fix(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) // which may occur outside of timestepping maxeatom = maxvatom = 0; - eatom = NULL; - vatom = NULL; vflag_atom = 0; // CUDA and KOKKOS per-fix data masks diff --git a/src/fix_adapt.cpp b/src/fix_adapt.cpp index 85e3bed562..48d93211a5 100644 --- a/src/fix_adapt.cpp +++ b/src/fix_adapt.cpp @@ -40,7 +40,8 @@ enum{DIAMETER,CHARGE}; /* ---------------------------------------------------------------------- */ -FixAdapt::FixAdapt(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) +FixAdapt::FixAdapt(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), +nadapt(0), id_fix_diam(NULL), id_fix_chg(NULL), adapt(NULL) { if (narg < 5) error->all(FLERR,"Illegal fix adapt command"); nevery = force->inumeric(FLERR,arg[3]); @@ -159,8 +160,6 @@ FixAdapt::FixAdapt(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) for (int m = 0; m < nadapt; m++) if (adapt[m].which == PAIR) memory->create(adapt[m].array_orig,n+1,n+1,"adapt:array_orig"); - - id_fix_diam = id_fix_chg = NULL; } /* ---------------------------------------------------------------------- */ diff --git a/src/fix_addforce.cpp b/src/fix_addforce.cpp index ac8384f2c0..b8520f2d53 100644 --- a/src/fix_addforce.cpp +++ b/src/fix_addforce.cpp @@ -36,7 +36,9 @@ enum{NONE,CONSTANT,EQUAL,ATOM}; /* ---------------------------------------------------------------------- */ FixAddForce::FixAddForce(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg) + Fix(lmp, narg, arg), + xstr(NULL), ystr(NULL), zstr(NULL), estr(NULL), idregion(NULL), sforce(NULL) + { if (narg < 6) error->all(FLERR,"Illegal fix addforce command"); @@ -81,8 +83,6 @@ FixAddForce::FixAddForce(LAMMPS *lmp, int narg, char **arg) : nevery = 1; iregion = -1; - idregion = NULL; - estr = NULL; int iarg = 6; while (iarg < narg) { diff --git a/src/fix_ave_atom.cpp b/src/fix_ave_atom.cpp index 2784537c67..92928f91d9 100644 --- a/src/fix_ave_atom.cpp +++ b/src/fix_ave_atom.cpp @@ -35,7 +35,8 @@ enum{X,V,F,COMPUTE,FIX,VARIABLE}; /* ---------------------------------------------------------------------- */ FixAveAtom::FixAveAtom(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg) + Fix(lmp, narg, arg), + nvalues(0), which(NULL), argindex(NULL), ids(NULL), value2index(NULL), array(NULL) { if (narg < 7) error->all(FLERR,"Illegal fix ave/atom command"); @@ -192,7 +193,6 @@ FixAveAtom::FixAveAtom(LAMMPS *lmp, int narg, char **arg) : // perform initial allocation of atom-based array // register with Atom class - array = NULL; grow_arrays(atom->nmax); atom->add_callback(0); diff --git a/src/fix_ave_correlate.cpp b/src/fix_ave_correlate.cpp index 18e16d1ea9..fffcc09d7a 100644 --- a/src/fix_ave_correlate.cpp +++ b/src/fix_ave_correlate.cpp @@ -44,7 +44,9 @@ enum{AUTO,UPPER,LOWER,AUTOUPPER,AUTOLOWER,FULL}; /* ---------------------------------------------------------------------- */ FixAveCorrelate::FixAveCorrelate(LAMMPS * lmp, int narg, char **arg): - Fix (lmp, narg, arg) + Fix (lmp, narg, arg), + nvalues(0), which(NULL), argindex(NULL), value2index(NULL), ids(NULL), fp(NULL), + count(NULL), values(NULL), corr(NULL), save_count(NULL), save_corr(NULL) { if (narg < 7) error->all(FLERR,"Illegal fix ave/correlate command"); diff --git a/src/fix_ave_histo.cpp b/src/fix_ave_histo.cpp index ff91f53ed6..e0d010aacb 100644 --- a/src/fix_ave_histo.cpp +++ b/src/fix_ave_histo.cpp @@ -45,7 +45,9 @@ enum{IGNORE,END,EXTRA}; /* ---------------------------------------------------------------------- */ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg) + Fix(lmp, narg, arg), + nvalues(0), which(NULL), argindex(NULL), value2index(NULL), ids(NULL), fp(NULL), stats_list(NULL), + bin(NULL), bin_total(NULL), bin_all(NULL), bin_list(NULL), coord(NULL), vector(NULL) { if (narg < 10) error->all(FLERR,"Illegal fix ave/histo command"); diff --git a/src/fix_ave_time.cpp b/src/fix_ave_time.cpp index 430c6069b7..ff47af03a8 100644 --- a/src/fix_ave_time.cpp +++ b/src/fix_ave_time.cpp @@ -42,7 +42,10 @@ enum{SCALAR,VECTOR}; /* ---------------------------------------------------------------------- */ FixAveTime::FixAveTime(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg) + Fix(lmp, narg, arg), + nvalues(0), which(NULL), argindex(NULL), value2index(NULL), offcol(NULL), varlen(NULL), ids(NULL), + fp(NULL), offlist(NULL), format(NULL), format_user(NULL), vector(NULL), vector_total(NULL), vector_list(NULL), + column(NULL), array(NULL), array_total(NULL), array_list(NULL) { if (narg < 7) error->all(FLERR,"Illegal fix ave/time command"); diff --git a/src/fix_aveforce.cpp b/src/fix_aveforce.cpp index 09a685cb1a..793c2d5c2b 100644 --- a/src/fix_aveforce.cpp +++ b/src/fix_aveforce.cpp @@ -34,7 +34,8 @@ enum{NONE,CONSTANT,EQUAL}; /* ---------------------------------------------------------------------- */ FixAveForce::FixAveForce(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg) + Fix(lmp, narg, arg), + xstr(NULL), ystr(NULL), zstr(NULL), idregion(NULL) { if (narg < 6) error->all(FLERR,"Illegal fix aveforce command");