This commit is contained in:
Axel Kohlmeyer 2021-03-13 22:51:53 -05:00
parent 56e3962d9c
commit 7936a6296f
No known key found for this signature in database
GPG Key ID: D9B44E93BF0C375A
3 changed files with 7 additions and 16 deletions

View File

@ -1826,10 +1826,10 @@ void Domain::delete_region(int narg, char **arg)
return -1 if no such region return -1 if no such region
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
int Domain::find_region(char *name) int Domain::find_region(const std::string &name)
{ {
for (int iregion = 0; iregion < nregion; iregion++) for (int iregion = 0; iregion < nregion; iregion++)
if (strcmp(name,regions[iregion]->id) == 0) return iregion; if (name == regions[iregion]->id) return iregion;
return -1; return -1;
} }

View File

@ -130,7 +130,7 @@ class Domain : protected Pointers {
void set_lattice(int, char **); void set_lattice(int, char **);
void add_region(int, char **); void add_region(int, char **);
void delete_region(int, char **); void delete_region(int, char **);
int find_region(char *); int find_region(const std::string &);
void set_boundary(int, char **, int); void set_boundary(int, char **, int);
void set_box(int, char **); void set_box(int, char **);
void print_box(const std::string &); void print_box(const std::string &);

View File

@ -66,10 +66,7 @@ Group::Group(LAMMPS *lmp) : Pointers(lmp)
// create "all" group // create "all" group
char *str = (char *) "all"; names[0] = utils::strdup("all");
int n = strlen(str) + 1;
names[0] = new char[n];
strcpy(names[0],str);
ngroup = 1; ngroup = 1;
} }
@ -157,9 +154,7 @@ void Group::assign(int narg, char **arg)
if (igroup == -1) { if (igroup == -1) {
if (ngroup == MAX_GROUP) error->all(FLERR,"Too many groups"); if (ngroup == MAX_GROUP) error->all(FLERR,"Too many groups");
igroup = find_unused(); igroup = find_unused();
int n = strlen(arg[0]) + 1; names[igroup] = utils::strdup(arg[0]);
names[igroup] = new char[n];
strcpy(names[igroup],arg[0]);
ngroup++; ngroup++;
} }
@ -563,9 +558,7 @@ void Group::create(char *name, int *flag)
if (igroup == -1) { if (igroup == -1) {
if (ngroup == MAX_GROUP) error->all(FLERR,"Too many groups"); if (ngroup == MAX_GROUP) error->all(FLERR,"Too many groups");
igroup = find_unused(); igroup = find_unused();
int n = strlen(name) + 1; names[igroup] = utils::strdup(name);
names[igroup] = new char[n];
strcpy(names[igroup],name);
ngroup++; ngroup++;
} }
@ -602,9 +595,7 @@ int Group::find_or_create(const char *name)
if (ngroup == MAX_GROUP) error->all(FLERR,"Too many groups"); if (ngroup == MAX_GROUP) error->all(FLERR,"Too many groups");
igroup = find_unused(); igroup = find_unused();
int n = strlen(name) + 1; names[igroup] = utils::strdup(name);
names[igroup] = new char[n];
strcpy(names[igroup],name);
ngroup++; ngroup++;
return igroup; return igroup;