fix memory leak in fix plumed
This commit is contained in:
@ -224,7 +224,8 @@ FixPlumed::FixPlumed(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
int ipe = modify->find_compute(id_pe);
|
int ipe = modify->find_compute(id_pe);
|
||||||
c_pe = modify->compute[ipe];
|
c_pe = modify->compute[ipe];
|
||||||
|
|
||||||
// Define compute to calculate pressure tensor
|
// Define compute to calculate pressure tensor
|
||||||
|
|
||||||
id_press = new char[9];
|
id_press = new char[9];
|
||||||
id_press = (char *) "plmd_press";
|
id_press = (char *) "plmd_press";
|
||||||
newarg = new char*[5];
|
newarg = new char*[5];
|
||||||
@ -268,6 +269,8 @@ FixPlumed::~FixPlumed()
|
|||||||
delete p;
|
delete p;
|
||||||
modify->delete_compute(id_pe);
|
modify->delete_compute(id_pe);
|
||||||
modify->delete_compute(id_press);
|
modify->delete_compute(id_press);
|
||||||
|
delete[] id_pe;
|
||||||
|
delete[] id_press;
|
||||||
delete[] masses;
|
delete[] masses;
|
||||||
delete[] charges;
|
delete[] charges;
|
||||||
delete[] gatindex;
|
delete[] gatindex;
|
||||||
@ -528,7 +531,8 @@ int FixPlumed::modify_param(int narg, char **arg)
|
|||||||
{
|
{
|
||||||
if (strcmp(arg[0],"pe") == 0) {
|
if (strcmp(arg[0],"pe") == 0) {
|
||||||
if (narg < 2) error->all(FLERR,"Illegal fix_modify command");
|
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;
|
int n = strlen(arg[1]) + 1;
|
||||||
id_pe = new char[n];
|
id_pe = new char[n];
|
||||||
strcpy(id_pe,arg[1]);
|
strcpy(id_pe,arg[1]);
|
||||||
@ -546,7 +550,8 @@ int FixPlumed::modify_param(int narg, char **arg)
|
|||||||
|
|
||||||
} else if (strcmp(arg[0],"press") == 0) {
|
} else if (strcmp(arg[0],"press") == 0) {
|
||||||
if (narg < 2) error->all(FLERR,"Illegal fix_modify command");
|
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;
|
int n = strlen(arg[1]) + 1;
|
||||||
id_press = new char[n];
|
id_press = new char[n];
|
||||||
strcpy(id_press,arg[1]);
|
strcpy(id_press,arg[1]);
|
||||||
|
|||||||
Reference in New Issue
Block a user