simplify using utils::strdup()
This commit is contained in:
@ -995,18 +995,14 @@ void Modify::replace_fix(const char *replaceID,
|
|||||||
if (jfix >= 0) error->all(FLERR,"Replace_fix ID is already in use");
|
if (jfix >= 0) error->all(FLERR,"Replace_fix ID is already in use");
|
||||||
|
|
||||||
delete [] fix[ifix]->id;
|
delete [] fix[ifix]->id;
|
||||||
int n = strlen(arg[0]) + 1;
|
fix[ifix]->id = utils::strdup(arg[0]);
|
||||||
fix[ifix]->id = new char[n];
|
|
||||||
strcpy(fix[ifix]->id,arg[0]);
|
|
||||||
|
|
||||||
int jgroup = group->find(arg[1]);
|
int jgroup = group->find(arg[1]);
|
||||||
if (jgroup == -1) error->all(FLERR,"Could not find replace_fix group ID");
|
if (jgroup == -1) error->all(FLERR,"Could not find replace_fix group ID");
|
||||||
fix[ifix]->igroup = jgroup;
|
fix[ifix]->igroup = jgroup;
|
||||||
|
|
||||||
delete [] fix[ifix]->style;
|
delete [] fix[ifix]->style;
|
||||||
n = strlen(arg[2]) + 1;
|
fix[ifix]->style = utils::strdup(arg[2]);
|
||||||
fix[ifix]->style = new char[n];
|
|
||||||
strcpy(fix[ifix]->style,arg[2]);
|
|
||||||
|
|
||||||
// invoke add_fix
|
// invoke add_fix
|
||||||
// it will find and overwrite the replaceID fix
|
// it will find and overwrite the replaceID fix
|
||||||
|
|||||||
@ -766,12 +766,8 @@ void Output::create_restart(int narg, char **arg)
|
|||||||
delete [] restart2a;
|
delete [] restart2a;
|
||||||
delete [] restart2b;
|
delete [] restart2b;
|
||||||
restart_toggle = 0;
|
restart_toggle = 0;
|
||||||
int n = strlen(arg[1]) + 3;
|
restart2a = utils::strdup(arg[1]);
|
||||||
restart2a = new char[n];
|
restart2b = utils::strdup(arg[2]);
|
||||||
strcpy(restart2a,arg[1]);
|
|
||||||
n = strlen(arg[2]) + 1;
|
|
||||||
restart2b = new char[n];
|
|
||||||
strcpy(restart2b,arg[2]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for multiproc output and an MPI-IO filename
|
// check for multiproc output and an MPI-IO filename
|
||||||
|
|||||||
@ -164,9 +164,7 @@ void PairCoulStreitz::coeff(int narg, char **arg)
|
|||||||
if (strcmp(arg[i],elements[j]) == 0) break;
|
if (strcmp(arg[i],elements[j]) == 0) break;
|
||||||
map[i-2] = j;
|
map[i-2] = j;
|
||||||
if (j == nelements) {
|
if (j == nelements) {
|
||||||
n = strlen(arg[i]) + 1;
|
elements[j] = utils::strdup(arg[i]);
|
||||||
elements[j] = new char[n];
|
|
||||||
strcpy(elements[j],arg[i]);
|
|
||||||
nelements++;
|
nelements++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user