Unverified Commit 8816d7fe authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

plug small memory leak in pair style eam/cd

parent b866ea68
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ PairEAMCD::~PairEAMCD()
{
  memory->destroy(rhoB);
  memory->destroy(D_values);
  if (hcoeff) delete[] hcoeff;
  delete[] hcoeff;
}

void PairEAMCD::compute(int eflag, int vflag)
@@ -521,6 +521,7 @@ void PairEAMCD::read_h_coeff(char *filename)
    if ((int)values.count() != nhcoeff + 1 || nhcoeff < 1)
      error->one(FLERR, "Failed to read h(x) function coefficients in EAM file.");

    delete[] hcoeff;
    hcoeff = new double[nhcoeff];

    int i = 0;
@@ -534,7 +535,10 @@ void PairEAMCD::read_h_coeff(char *filename)
  }

  MPI_Bcast(&nhcoeff, 1, MPI_INT, 0, world);
  if (comm->me != 0) hcoeff = new double[nhcoeff];
  if (comm->me != 0) {
    delete[] hcoeff;
    hcoeff = new double[nhcoeff];
  }
  MPI_Bcast(hcoeff, nhcoeff, MPI_DOUBLE, 0, world);
}