simplify by using utils::strdup()

This commit is contained in:
Axel Kohlmeyer
2021-03-18 19:58:04 -04:00
parent c5ab2becd7
commit 59c0325f08
29 changed files with 53 additions and 135 deletions

View File

@ -53,9 +53,7 @@ ComputeDisplaceAtom::ComputeDisplaceAtom(LAMMPS *lmp, int narg, char **arg) :
error->all(FLERR,"Illegal compute displace/atom command");
refreshflag = 1;
delete [] rvar;
int n = strlen(arg[iarg+1]) + 1;
rvar = new char[n];
strcpy(rvar,arg[iarg+1]);
rvar = utils::strdup(arg[iarg+1]);
iarg += 2;
} else error->all(FLERR,"Illegal compute displace/atom command");
}
@ -74,11 +72,9 @@ ComputeDisplaceAtom::ComputeDisplaceAtom(LAMMPS *lmp, int narg, char **arg) :
// create a new fix STORE style
// id = compute-ID + COMPUTE_STORE, fix group = compute group
std::string cmd = id + std::string("_COMPUTE_STORE");
id_fix = new char[cmd.size()+1];
strcpy(id_fix,cmd.c_str());
cmd += fmt::format(" {} STORE peratom 1 3", group->names[igroup]);
id_fix = utils::strdup(std::string(id) + "_COMPUTE_STORE");
std::string cmd = id_fix + fmt::format(" {} STORE peratom 1 3",
group->names[igroup]);
modify->add_fix(cmd);
fix = (FixStore *) modify->fix[modify->nfix-1];