simplify some more code by using utils::strdup()

This commit is contained in:
Axel Kohlmeyer
2021-03-17 00:10:01 -04:00
parent a76a8eae59
commit 2dc0b70575
4 changed files with 12 additions and 33 deletions

View File

@ -1013,9 +1013,7 @@ void Input::jump()
if (narg == 2) {
label_active = 1;
if (labelstr) delete [] labelstr;
int n = strlen(arg[1]) + 1;
labelstr = new char[n];
strcpy(labelstr,arg[1]);
labelstr = utils::strdup(arg[1]);
}
}
@ -1840,17 +1838,12 @@ void Input::suffix()
if (strcmp(arg[0],"hybrid") == 0) {
if (narg != 3) error->all(FLERR,"Illegal suffix command");
int n = strlen(arg[1]) + 1;
lmp->suffix = new char[n];
strcpy(lmp->suffix,arg[1]);
lmp->suffix = utils::strdup(arg[1]);
n = strlen(arg[2]) + 1;
lmp->suffix2 = new char[n];
strcpy(lmp->suffix2,arg[2]);
lmp->suffix2 = utils::strdup(arg[2]);
} else {
if (narg != 1) error->all(FLERR,"Illegal suffix command");
int n = strlen(arg[0]) + 1;
lmp->suffix = new char[n];
strcpy(lmp->suffix,arg[0]);
lmp->suffix = utils::strdup(arg[0]);
}
}
}