simplify by using utils::strdup()
This commit is contained in:
@ -39,12 +39,9 @@ RegIntersect::RegIntersect(LAMMPS *lmp, int narg, char **arg) :
|
||||
list = new int[n];
|
||||
nregion = 0;
|
||||
|
||||
int m,iregion;
|
||||
for (int iarg = 0; iarg < n; iarg++) {
|
||||
m = strlen(arg[iarg+3]) + 1;
|
||||
idsub[nregion] = new char[m];
|
||||
strcpy(idsub[nregion],arg[iarg+3]);
|
||||
iregion = domain->find_region(idsub[nregion]);
|
||||
idsub[nregion] = utils::strdup(arg[iarg+3]);
|
||||
int iregion = domain->find_region(idsub[nregion]);
|
||||
if (iregion == -1)
|
||||
error->all(FLERR,"Region intersect region ID does not exist");
|
||||
list[nregion++] = iregion;
|
||||
@ -123,9 +120,8 @@ void RegIntersect::init()
|
||||
// re-build list of sub-regions in case other regions were deleted
|
||||
// error if a sub-region was deleted
|
||||
|
||||
int iregion;
|
||||
for (int ilist = 0; ilist < nregion; ilist++) {
|
||||
iregion = domain->find_region(idsub[ilist]);
|
||||
int iregion = domain->find_region(idsub[ilist]);
|
||||
if (iregion == -1)
|
||||
error->all(FLERR,"Region union region ID does not exist");
|
||||
list[ilist] = iregion;
|
||||
|
||||
Reference in New Issue
Block a user