use utils::strdup() for duplicating strings

This commit is contained in:
Axel Kohlmeyer
2021-03-15 15:31:25 -04:00
parent a6a2879807
commit ece2433208
6 changed files with 21 additions and 54 deletions

View File

@ -109,8 +109,7 @@ void AtomVecHybrid::process_args(int narg, char **arg)
if (strcmp(arg[iarg],keywords[i]) == 0)
error->all(FLERR,"Atom style hybrid cannot use same atom style twice");
styles[nstyles] = atom->new_avec(arg[iarg],1,dummy);
keywords[nstyles] = new char[strlen(arg[iarg])+1];
strcpy(keywords[nstyles],arg[iarg]);
keywords[nstyles] = utils::strdup(arg[iarg]);
jarg = iarg + 1;
while (jarg < narg && !known_style(arg[jarg])) jarg++;
styles[nstyles]->process_args(jarg-iarg-1,&arg[iarg+1]);
@ -601,13 +600,10 @@ void AtomVecHybrid::build_styles()
allstyles = new char*[nallstyles];
int n;
nallstyles = 0;
#define ATOM_CLASS
#define AtomStyle(key,Class) \
n = strlen(#key) + 1; \
allstyles[nallstyles] = new char[n]; \
strcpy(allstyles[nallstyles],#key); \
#define AtomStyle(key,Class) \
allstyles[nallstyles] = utils::strdup(#key); \
nallstyles++;
#include "style_atom.h" // IWYU pragma: keep
#undef AtomStyle