apply utils::strdup() in a few more cases

This commit is contained in:
Axel Kohlmeyer
2021-02-04 17:52:32 -05:00
parent 5c8bbb42f6
commit cf427bcad8
14 changed files with 83 additions and 159 deletions

View File

@ -49,9 +49,7 @@ FixSetForce::FixSetForce(LAMMPS *lmp, int narg, char **arg) :
xstr = ystr = zstr = nullptr;
if (utils::strmatch(arg[3],"^v_")) {
int n = strlen(&arg[3][2]) + 1;
xstr = new char[n];
strcpy(xstr,&arg[3][2]);
xstr = utils::strdup(arg[3]+2);
} else if (strcmp(arg[3],"NULL") == 0) {
xstyle = NONE;
} else {
@ -59,9 +57,7 @@ FixSetForce::FixSetForce(LAMMPS *lmp, int narg, char **arg) :
xstyle = CONSTANT;
}
if (utils::strmatch(arg[4],"^v_")) {
int n = strlen(&arg[4][2]) + 1;
ystr = new char[n];
strcpy(ystr,&arg[4][2]);
ystr = utils::strdup(arg[4]+2);
} else if (strcmp(arg[4],"NULL") == 0) {
ystyle = NONE;
} else {
@ -69,9 +65,7 @@ FixSetForce::FixSetForce(LAMMPS *lmp, int narg, char **arg) :
ystyle = CONSTANT;
}
if (utils::strmatch(arg[5],"^v_")) {
int n = strlen(&arg[5][2]) + 1;
zstr = new char[n];
strcpy(zstr,&arg[5][2]);
zstr = utils::strdup(arg[5]+2);
} else if (strcmp(arg[5],"NULL") == 0) {
zstyle = NONE;
} else {
@ -91,9 +85,7 @@ FixSetForce::FixSetForce(LAMMPS *lmp, int narg, char **arg) :
iregion = domain->find_region(arg[iarg+1]);
if (iregion == -1)
error->all(FLERR,"Region ID for fix setforce does not exist");
int n = strlen(arg[iarg+1]) + 1;
idregion = new char[n];
strcpy(idregion,arg[iarg+1]);
idregion = utils::strdup(arg[iarg+1]);
iarg += 2;
} else error->all(FLERR,"Illegal fix setforce command");
}