simplify by using utils::strdup()
This commit is contained in:
@ -37,10 +37,10 @@ ComputePair::ComputePair(LAMMPS *lmp, int narg, char **arg) :
|
||||
peflag = 1;
|
||||
timeflag = 1;
|
||||
|
||||
int n = strlen(arg[3]) + 1;
|
||||
if (lmp->suffix) n += strlen(lmp->suffix) + 1;
|
||||
pstyle = new char[n];
|
||||
strcpy(pstyle,arg[3]);
|
||||
// copy with suffix so we can later chop it off, if needed
|
||||
if (lmp->suffix)
|
||||
pstyle = utils::strdup(fmt::format("{}/{}",arg[3],lmp->suffix));
|
||||
else pstyle = utils::strdup(arg[3]);
|
||||
|
||||
int iarg = 4;
|
||||
nsub = 0;
|
||||
@ -67,8 +67,7 @@ ComputePair::ComputePair(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
pair = force->pair_match(pstyle,1,nsub);
|
||||
if (!pair && lmp->suffix) {
|
||||
strcat(pstyle,"/");
|
||||
strcat(pstyle,lmp->suffix);
|
||||
pstyle[strlen(pstyle) - strlen(lmp->suffix) - 1] = '\0';
|
||||
pair = force->pair_match(pstyle,1,nsub);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user