simplify by using utils::strdup()

This commit is contained in:
Axel Kohlmeyer
2021-03-16 08:35:06 -04:00
parent 2f8770971c
commit 5d5fc4a04d
6 changed files with 19 additions and 57 deletions

View File

@ -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;