use utils::strdup() for duplicating strings
This commit is contained in:
23
src/comm.cpp
23
src/comm.cpp
@ -149,16 +149,11 @@ void Comm::copy_arrays(Comm *oldcomm)
|
||||
memcpy(cutusermulti,oldcomm->cutusermulti,atom->ntypes+1);
|
||||
}
|
||||
|
||||
if (customfile) {
|
||||
int n = strlen(oldcomm->customfile) + 1;
|
||||
customfile = new char[n];
|
||||
strcpy(customfile,oldcomm->customfile);
|
||||
}
|
||||
if (outfile) {
|
||||
int n = strlen(oldcomm->outfile) + 1;
|
||||
outfile = new char[n];
|
||||
strcpy(outfile,oldcomm->outfile);
|
||||
}
|
||||
if (customfile)
|
||||
customfile = utils::strdup(oldcomm->customfile);
|
||||
|
||||
if (outfile)
|
||||
outfile = utils::strdup(oldcomm->outfile);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -391,9 +386,7 @@ void Comm::set_processors(int narg, char **arg)
|
||||
if (iarg+3 > narg) error->all(FLERR,"Illegal processors command");
|
||||
gridflag = CUSTOM;
|
||||
delete [] customfile;
|
||||
int n = strlen(arg[iarg+2]) + 1;
|
||||
customfile = new char[n];
|
||||
strcpy(customfile,arg[iarg+2]);
|
||||
customfile = utils::strdup(arg[iarg+2]);
|
||||
iarg += 1;
|
||||
|
||||
} else error->all(FLERR,"Illegal processors command");
|
||||
@ -453,9 +446,7 @@ void Comm::set_processors(int narg, char **arg)
|
||||
} else if (strcmp(arg[iarg],"file") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal processors command");
|
||||
delete [] outfile;
|
||||
int n = strlen(arg[iarg+1]) + 1;
|
||||
outfile = new char[n];
|
||||
strcpy(outfile,arg[iarg+1]);
|
||||
outfile = utils::strdup(arg[iarg+1]);
|
||||
iarg += 2;
|
||||
|
||||
} else error->all(FLERR,"Illegal processors command");
|
||||
|
||||
Reference in New Issue
Block a user