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

@ -49,22 +49,15 @@ Compute::Compute(LAMMPS *lmp, int narg, char **arg) :
// compute ID, group, and style
// ID must be all alphanumeric chars or underscores
int n = strlen(arg[0]) + 1;
id = new char[n];
strcpy(id,arg[0]);
for (int i = 0; i < n-1; i++)
if (!isalnum(id[i]) && id[i] != '_')
error->all(FLERR,
"Compute ID must be alphanumeric or underscore characters");
id = utils::strdup(arg[0]);
if (!utils::is_id(id))
error->all(FLERR,"Compute ID must be alphanumeric or underscore characters");
igroup = group->find(arg[1]);
if (igroup == -1) error->all(FLERR,"Could not find compute group ID");
groupbit = group->bitmask[igroup];
n = strlen(arg[2]) + 1;
style = new char[n];
strcpy(style,arg[2]);
style = utils::strdup(arg[2]);
// set child class defaults