simplify by using utils::strdup()
This commit is contained in:
@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user