From 9c8431bf87dda3d7b87f5acbfc99f7dc79890225 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 21 Jan 2022 06:55:06 -0500 Subject: [PATCH] correct calls to memset() --- src/EXTRA-FIX/fix_gle.cpp | 5 ++--- src/EXTRA-PAIR/pair_e3b.cpp | 3 +-- src/EXTRA-PAIR/pair_e3b.h | 1 - src/MOLECULE/fix_cmap.cpp | 2 +- src/REAXFF/fix_acks2_reaxff.cpp | 2 +- src/REAXFF/fix_qeq_reaxff.cpp | 2 +- 6 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/EXTRA-FIX/fix_gle.cpp b/src/EXTRA-FIX/fix_gle.cpp index d7061e199c..acb7b84fe1 100644 --- a/src/EXTRA-FIX/fix_gle.cpp +++ b/src/EXTRA-FIX/fix_gle.cpp @@ -211,6 +211,8 @@ FixGLE::FixGLE(LAMMPS *lmp, int narg, char **arg) : S = new double[ns1sq]; TT = new double[ns1sq]; ST = new double[ns1sq]; + memset(A,0,sizeof(double)*ns1sq); + memset(C,0,sizeof(double)*ns1sq); // start temperature (t ramp) t_start = utils::numeric(FLERR,arg[4],false,lmp); @@ -223,7 +225,6 @@ FixGLE::FixGLE(LAMMPS *lmp, int narg, char **arg) : // LOADING A matrix char *fname = arg[7]; - memset(A, ns1sq, sizeof(double)); if (comm->me == 0) { PotentialFileReader reader(lmp,fname,"fix gle A matrix"); try { @@ -256,14 +257,12 @@ FixGLE::FixGLE(LAMMPS *lmp, int narg, char **arg) : if (fnoneq == 0) { t_target=t_start; const double kT = t_target * force->boltz / force->mvv2e; - memset(C,0,sizeof(double)*ns1sq); for (int i=0; ime == 0) { PotentialFileReader reader(lmp,fname,"fix gle C matrix"); try { diff --git a/src/EXTRA-PAIR/pair_e3b.cpp b/src/EXTRA-PAIR/pair_e3b.cpp index 7e865ac6f8..3af8e754c0 100644 --- a/src/EXTRA-PAIR/pair_e3b.cpp +++ b/src/EXTRA-PAIR/pair_e3b.cpp @@ -99,7 +99,7 @@ void PairE3B::compute(int eflag, int vflag) ev_init(eflag, vflag); //clear sumExp array - memset(sumExp, 0.0, nbytes); + memset(sumExp, 0, sizeof(double)*maxID); evdwl = 0.0; pvector[0] = pvector[1] = pvector[2] = pvector[3] = 0.0; @@ -364,7 +364,6 @@ void PairE3B::allocateE3B() maxID = find_maxID(); if (!natoms) error->all(FLERR, "No atoms found"); memory->create(sumExp, maxID, "pair:sumExp"); - nbytes = sizeof(double) * maxID; } /* ---------------------------------------------------------------------- diff --git a/src/EXTRA-PAIR/pair_e3b.h b/src/EXTRA-PAIR/pair_e3b.h index f6cf916918..1f38c18293 100644 --- a/src/EXTRA-PAIR/pair_e3b.h +++ b/src/EXTRA-PAIR/pair_e3b.h @@ -50,7 +50,6 @@ class PairE3B : public Pair { int **pairO, ***pairH; // pair lists double ***exps, ****del3, ***fpair3, *sumExp; int maxID; //size of global sumExp array - size_t nbytes; //size of sumExp array in bytes int natoms; //to make sure number of atoms is constant virtual void allocate(); diff --git a/src/MOLECULE/fix_cmap.cpp b/src/MOLECULE/fix_cmap.cpp index c6e356e829..34f54ef26c 100644 --- a/src/MOLECULE/fix_cmap.cpp +++ b/src/MOLECULE/fix_cmap.cpp @@ -637,7 +637,7 @@ void FixCMAP::read_grid_map(char *cmapfile) { if (comm->me == 0) { try { - memset(&cmapgrid[0][0][0], 6*CMAPDIM*CMAPDIM, sizeof(double)); + memset(&cmapgrid[0][0][0], 0, 6*CMAPDIM*CMAPDIM*sizeof(double)); PotentialFileReader reader(lmp, cmapfile, "cmap grid"); // there are six maps in this order. diff --git a/src/REAXFF/fix_acks2_reaxff.cpp b/src/REAXFF/fix_acks2_reaxff.cpp index b6789b1b2e..21cce5b55a 100644 --- a/src/REAXFF/fix_acks2_reaxff.cpp +++ b/src/REAXFF/fix_acks2_reaxff.cpp @@ -429,7 +429,7 @@ void FixACKS2ReaxFF::compute_X() double **x = atom->x; int *mask = atom->mask; - memset(X_diag,0.0,atom->nmax*sizeof(double)); + memset(X_diag,0,atom->nmax*sizeof(double)); // fill in the X matrix m_fill = 0; diff --git a/src/REAXFF/fix_qeq_reaxff.cpp b/src/REAXFF/fix_qeq_reaxff.cpp index fa8fa79e00..08a4e21fe5 100644 --- a/src/REAXFF/fix_qeq_reaxff.cpp +++ b/src/REAXFF/fix_qeq_reaxff.cpp @@ -1084,7 +1084,7 @@ void FixQEqReaxFF::vector_add(double* dest, double c, double* v, int k) void FixQEqReaxFF::get_chi_field() { - memset(&chi_field[0],0.0,atom->nmax*sizeof(double)); + memset(&chi_field[0],0,atom->nmax*sizeof(double)); if (!efield) return; const double * const *x = (const double * const *)atom->x;