simplify using utils::strdup()
This commit is contained in:
@ -948,18 +948,14 @@ void FixPour::options(int narg, char **arg)
|
||||
|
||||
} else if (strcmp(arg[iarg],"rigid") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix pour command");
|
||||
int n = strlen(arg[iarg+1]) + 1;
|
||||
delete [] idrigid;
|
||||
idrigid = new char[n];
|
||||
strcpy(idrigid,arg[iarg+1]);
|
||||
idrigid = utils::strdup(arg[iarg+1]);
|
||||
rigidflag = 1;
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"shake") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix pour command");
|
||||
int n = strlen(arg[iarg+1]) + 1;
|
||||
delete [] idshake;
|
||||
idshake = new char[n];
|
||||
strcpy(idshake,arg[iarg+1]);
|
||||
idshake = utils::strdup(arg[iarg+1]);
|
||||
shakeflag = 1;
|
||||
iarg += 2;
|
||||
|
||||
|
||||
@ -338,9 +338,7 @@ FixWallGran::FixWallGran(LAMMPS *lmp, int narg, char **arg) :
|
||||
} else if (strcmp(arg[iarg],"region") == 0) {
|
||||
if (narg < iarg+2) error->all(FLERR,"Illegal fix wall/gran command");
|
||||
wallstyle = REGION;
|
||||
int n = strlen(arg[iarg+1]) + 1;
|
||||
idregion = new char[n];
|
||||
strcpy(idregion,arg[iarg+1]);
|
||||
idregion = utils::strdup(arg[iarg+1]);
|
||||
iarg += 2;
|
||||
}
|
||||
|
||||
|
||||
@ -257,9 +257,7 @@ int AtomKokkos::add_custom(const char *name, int flag)
|
||||
nivector++;
|
||||
iname = (char **) memory->srealloc(iname,nivector*sizeof(char *),
|
||||
"atom:iname");
|
||||
int n = strlen(name) + 1;
|
||||
iname[index] = new char[n];
|
||||
strcpy(iname[index],name);
|
||||
iname[index] = utils::strdup(name);
|
||||
ivector = (int **) memory->srealloc(ivector,nivector*sizeof(int *),
|
||||
"atom:ivector");
|
||||
memory->create(ivector[index],nmax,"atom:ivector");
|
||||
@ -268,9 +266,7 @@ int AtomKokkos::add_custom(const char *name, int flag)
|
||||
ndvector++;
|
||||
dname = (char **) memory->srealloc(dname,ndvector*sizeof(char *),
|
||||
"atom:dname");
|
||||
int n = strlen(name) + 1;
|
||||
dname[index] = new char[n];
|
||||
strcpy(dname[index],name);
|
||||
dname[index] = utils::strdup(name);
|
||||
this->sync(Device,DVECTOR_MASK);
|
||||
memoryKK->grow_kokkos(k_dvector,dvector,ndvector,nmax,
|
||||
"atom:dvector");
|
||||
|
||||
@ -72,8 +72,7 @@ void AtomVecHybridKokkos::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]);
|
||||
@ -1175,10 +1174,8 @@ void AtomVecHybridKokkos::build_styles()
|
||||
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
|
||||
|
||||
@ -29,45 +29,26 @@ FixNPHKokkos<DeviceType>::FixNPHKokkos(LAMMPS *lmp, int narg, char **arg) :
|
||||
{
|
||||
this->kokkosable = 1;
|
||||
if (this->tstat_flag)
|
||||
this->error->all(FLERR,"Temperature control can not be used with fix nph");
|
||||
this->error->all(FLERR,"Temperature control can not be used with fix nph/kk");
|
||||
if (!this->pstat_flag)
|
||||
this->error->all(FLERR,"Pressure control must be used with fix nph");
|
||||
this->error->all(FLERR,"Pressure control must be used with fix nph/kk");
|
||||
|
||||
// create a new compute temp style
|
||||
// id = fix-ID + temp
|
||||
// compute group = all since pressure is always global (group all)
|
||||
// and thus its KE/temperature contribution should use group all
|
||||
|
||||
int n = strlen(this->id) + 6;
|
||||
this->id_temp = new char[n];
|
||||
strcpy(this->id_temp,this->id);
|
||||
strcat(this->id_temp,"_temp");
|
||||
|
||||
char **newarg = new char*[3];
|
||||
newarg[0] = this->id_temp;
|
||||
newarg[1] = (char *) "all";
|
||||
newarg[2] = (char *) "temp/kk";
|
||||
|
||||
this->modify->add_compute(3,newarg);
|
||||
delete [] newarg;
|
||||
this->id_temp = utils::strdup(std::string(this->id)+"_temp");
|
||||
this->modify->add_compute(std::string(this->id_temp)+" all temp/kk");
|
||||
this->tcomputeflag = 1;
|
||||
|
||||
// create a new compute pressure style
|
||||
// id = fix-ID + press, compute group = all
|
||||
// pass id_temp as 4th arg to pressure constructor
|
||||
|
||||
n = strlen(this->id) + 7;
|
||||
this->id_press = new char[n];
|
||||
strcpy(this->id_press,this->id);
|
||||
strcat(this->id_press,"_press");
|
||||
|
||||
newarg = new char*[4];
|
||||
newarg[0] = this->id_press;
|
||||
newarg[1] = (char *) "all";
|
||||
newarg[2] = (char *) "pressure";
|
||||
newarg[3] = this->id_temp;
|
||||
this->modify->add_compute(4,newarg);
|
||||
delete [] newarg;
|
||||
this->id_press = utils::strdup(std::string(this->id)+"_press");
|
||||
this->modify->add_compute(std::string(this->id_press)
|
||||
+" all pressure "+this->id_temp);
|
||||
this->pcomputeflag = 1;
|
||||
}
|
||||
|
||||
|
||||
@ -29,45 +29,26 @@ FixNPTKokkos<DeviceType>::FixNPTKokkos(LAMMPS *lmp, int narg, char **arg) :
|
||||
{
|
||||
this->kokkosable = 1;
|
||||
if (!this->tstat_flag)
|
||||
this->error->all(FLERR,"Temperature control must be used with fix npt");
|
||||
this->error->all(FLERR,"Temperature control must be used with fix npt/kk");
|
||||
if (!this->pstat_flag)
|
||||
this->error->all(FLERR,"Pressure control must be used with fix npt");
|
||||
this->error->all(FLERR,"Pressure control must be used with fix npt/kk");
|
||||
|
||||
// create a new compute temp style
|
||||
// id = fix-ID + temp
|
||||
// compute group = all since pressure is always global (group all)
|
||||
// and thus its KE/temperature contribution should use group all
|
||||
|
||||
int n = strlen(this->id) + 6;
|
||||
this->id_temp = new char[n];
|
||||
strcpy(this->id_temp,this->id);
|
||||
strcat(this->id_temp,"_temp");
|
||||
|
||||
char **newarg = new char*[3];
|
||||
newarg[0] = this->id_temp;
|
||||
newarg[1] = (char *) "all";
|
||||
newarg[2] = (char *) "temp/kk";
|
||||
|
||||
this->modify->add_compute(3,newarg);
|
||||
delete [] newarg;
|
||||
this->id_temp = utils::strdup(std::string(this->id)+"_temp");
|
||||
this->modify->add_compute(std::string(this->id_temp)+" all temp/kk");
|
||||
this->tcomputeflag = 1;
|
||||
|
||||
// create a new compute pressure style
|
||||
// id = fix-ID + press, compute group = all
|
||||
// pass id_temp as 4th arg to pressure constructor
|
||||
|
||||
n = strlen(this->id) + 7;
|
||||
this->id_press = new char[n];
|
||||
strcpy(this->id_press,this->id);
|
||||
strcat(this->id_press,"_press");
|
||||
|
||||
newarg = new char*[4];
|
||||
newarg[0] = this->id_press;
|
||||
newarg[1] = (char *) "all";
|
||||
newarg[2] = (char *) "pressure";
|
||||
newarg[3] = this->id_temp;
|
||||
this->modify->add_compute(4,newarg);
|
||||
delete [] newarg;
|
||||
this->id_press = utils::strdup(std::string(this->id)+"_press");
|
||||
this->modify->add_compute(std::string(this->id_press)
|
||||
+" all pressure "+this->id_temp);
|
||||
this->pcomputeflag = 1;
|
||||
}
|
||||
|
||||
|
||||
@ -30,25 +30,15 @@ FixNVTKokkos<DeviceType>::FixNVTKokkos(LAMMPS *lmp, int narg, char **arg) :
|
||||
{
|
||||
this->kokkosable = 1;
|
||||
if (!this->tstat_flag)
|
||||
this->error->all(FLERR,"Temperature control must be used with fix nvt");
|
||||
this->error->all(FLERR,"Temperature control must be used with fix nvt/kk");
|
||||
if (this->pstat_flag)
|
||||
this->error->all(FLERR,"Pressure control can not be used with fix nvt");
|
||||
this->error->all(FLERR,"Pressure control can not be used with fix nvt/kk");
|
||||
|
||||
// create a new compute temp style
|
||||
// id = fix-ID + temp
|
||||
|
||||
int n = strlen(this->id) + 6;
|
||||
this->id_temp = new char[n];
|
||||
strcpy(this->id_temp,this->id);
|
||||
strcat(this->id_temp,"_temp");
|
||||
|
||||
char **newarg = new char*[3];
|
||||
newarg[0] = this->id_temp;
|
||||
newarg[1] = this->group->names[this->igroup];
|
||||
newarg[2] = (char *) "temp/kk";
|
||||
|
||||
this->modify->add_compute(3,newarg);
|
||||
delete [] newarg;
|
||||
this->id_temp = utils::strdup(std::string(this->id)+"_temp");
|
||||
this->modify->add_compute(std::string(this->id_temp)+" all temp/kk");
|
||||
this->tcomputeflag = 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user