Commit 984f4151 authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

fix memory leak in fix plumed

parent e01ba84f
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -225,6 +225,7 @@ FixPlumed::FixPlumed(LAMMPS *lmp, int narg, char **arg) :
  c_pe = modify->compute[ipe];

  // Define compute to calculate pressure tensor

  id_press = new char[9];
  id_press = (char *) "plmd_press";
  newarg = new char*[5];
@@ -268,6 +269,8 @@ FixPlumed::~FixPlumed()
  delete p;
  modify->delete_compute(id_pe);
  modify->delete_compute(id_press);
  delete[] id_pe;
  delete[] id_press;
  delete[] masses;
  delete[] charges;
  delete[] gatindex;
@@ -528,7 +531,8 @@ int FixPlumed::modify_param(int narg, char **arg)
{
  if (strcmp(arg[0],"pe") == 0) {
    if (narg < 2) error->all(FLERR,"Illegal fix_modify command");
    modify->delete_compute(id_pe); delete [] id_pe;
    modify->delete_compute(id_pe);
    delete[] id_pe;
    int n = strlen(arg[1]) + 1;
    id_pe = new char[n];
    strcpy(id_pe,arg[1]);
@@ -546,7 +550,8 @@ int FixPlumed::modify_param(int narg, char **arg)

  } else if (strcmp(arg[0],"press") == 0) {
    if (narg < 2) error->all(FLERR,"Illegal fix_modify command");
    modify->delete_compute(id_press); delete [] id_press;
    modify->delete_compute(id_press);
    delete[] id_press;
    int n = strlen(arg[1]) + 1;
    id_press = new char[n];
    strcpy(id_press,arg[1]);