diff --git a/src/compute.cpp b/src/compute.cpp index df2bf9429c..81e317076c 100644 --- a/src/compute.cpp +++ b/src/compute.cpp @@ -49,22 +49,15 @@ Compute::Compute(LAMMPS *lmp, int narg, char **arg) : // compute ID, group, and style // ID must be all alphanumeric chars or underscores - int n = strlen(arg[0]) + 1; - id = new char[n]; - strcpy(id,arg[0]); - - for (int i = 0; i < n-1; i++) - if (!isalnum(id[i]) && id[i] != '_') - error->all(FLERR, - "Compute ID must be alphanumeric or underscore characters"); + id = utils::strdup(arg[0]); + if (!utils::is_id(id)) + error->all(FLERR,"Compute ID must be alphanumeric or underscore characters"); igroup = group->find(arg[1]); if (igroup == -1) error->all(FLERR,"Could not find compute group ID"); groupbit = group->bitmask[igroup]; - n = strlen(arg[2]) + 1; - style = new char[n]; - strcpy(style,arg[2]); + style = utils::strdup(arg[2]); // set child class defaults diff --git a/src/compute_angle_local.cpp b/src/compute_angle_local.cpp index 8e24eccf01..d0630f07eb 100644 --- a/src/compute_angle_local.cpp +++ b/src/compute_angle_local.cpp @@ -67,9 +67,7 @@ ComputeAngleLocal::ComputeAngleLocal(LAMMPS *lmp, int narg, char **arg) : bstyle[nvalues++] = ENG; } else if (strncmp(arg[iarg],"v_",2) == 0) { bstyle[nvalues++] = VARIABLE; - int n = strlen(arg[iarg]); - vstr[nvar] = new char[n]; - strcpy(vstr[nvar],&arg[iarg][2]); + vstr[nvar] = utils::strdup(&arg[iarg][2]); nvar++; } else break; } @@ -85,9 +83,7 @@ ComputeAngleLocal::ComputeAngleLocal(LAMMPS *lmp, int narg, char **arg) : if (iarg+3 > narg) error->all(FLERR,"Illegal compute angle/local command"); if (strcmp(arg[iarg+1],"theta") == 0) { delete [] tstr; - int n = strlen(arg[iarg+2]) + 1; - tstr = new char[n]; - strcpy(tstr,arg[iarg+2]); + tstr = utils::strdup(arg[iarg+2]); tflag = 1; } else error->all(FLERR,"Illegal compute angle/local command"); iarg += 3; diff --git a/src/compute_angmom_chunk.cpp b/src/compute_angmom_chunk.cpp index d35f274d7a..39cae07503 100644 --- a/src/compute_angmom_chunk.cpp +++ b/src/compute_angmom_chunk.cpp @@ -41,9 +41,7 @@ ComputeAngmomChunk::ComputeAngmomChunk(LAMMPS *lmp, int narg, char **arg) : // ID of compute chunk/atom - int n = strlen(arg[3]) + 1; - idchunk = new char[n]; - strcpy(idchunk,arg[3]); + idchunk = utils::strdup(arg[3]); init(); diff --git a/src/compute_bond_local.cpp b/src/compute_bond_local.cpp index d13f313aea..053c4c83dc 100644 --- a/src/compute_bond_local.cpp +++ b/src/compute_bond_local.cpp @@ -74,9 +74,7 @@ ComputeBondLocal::ComputeBondLocal(LAMMPS *lmp, int narg, char **arg) : else if (strcmp(arg[iarg],"velvib") == 0) bstyle[nvalues++] = VELVIB; else if (strncmp(arg[iarg],"v_",2) == 0) { bstyle[nvalues++] = VARIABLE; - int n = strlen(arg[iarg]); - vstr[nvar] = new char[n]; - strcpy(vstr[nvar],&arg[iarg][2]); + vstr[nvar] = utils::strdup(&arg[iarg][2]); nvar++; } else break; } @@ -92,9 +90,7 @@ ComputeBondLocal::ComputeBondLocal(LAMMPS *lmp, int narg, char **arg) : if (iarg+3 > narg) error->all(FLERR,"Illegal compute bond/local command"); if (strcmp(arg[iarg+1],"dist") == 0) { delete [] dstr; - int n = strlen(arg[iarg+2]) + 1; - dstr = new char[n]; - strcpy(dstr,arg[iarg+2]); + dstr = utils::strdup(arg[iarg+2]); } else error->all(FLERR,"Illegal compute bond/local command"); iarg += 3; } else error->all(FLERR,"Illegal compute bond/local command"); diff --git a/src/compute_centroid_stress_atom.cpp b/src/compute_centroid_stress_atom.cpp index 9ad871382c..a0abbe8406 100644 --- a/src/compute_centroid_stress_atom.cpp +++ b/src/compute_centroid_stress_atom.cpp @@ -51,9 +51,7 @@ ComputeCentroidStressAtom::ComputeCentroidStressAtom(LAMMPS *lmp, int narg, char if (strcmp(arg[3],"NULL") == 0) id_temp = nullptr; else { - int n = strlen(arg[3]) + 1; - id_temp = new char[n]; - strcpy(id_temp,arg[3]); + id_temp = utils::strdup(arg[3]); int icompute = modify->find_compute(id_temp); if (icompute < 0) diff --git a/src/compute_chunk_atom.cpp b/src/compute_chunk_atom.cpp index 2800c9129b..be1e1e1035 100644 --- a/src/compute_chunk_atom.cpp +++ b/src/compute_chunk_atom.cpp @@ -185,9 +185,7 @@ ComputeChunkAtom::ComputeChunkAtom(LAMMPS *lmp, int narg, char **arg) : int iregion = domain->find_region(arg[iarg+1]); if (iregion == -1) error->all(FLERR,"Region ID for compute chunk/atom does not exist"); - int n = strlen(arg[iarg+1]) + 1; - idregion = new char[n]; - strcpy(idregion,arg[iarg+1]); + idregion = utils::strdup(arg[iarg+1]); regionflag = 1; iarg += 2; } else if (strcmp(arg[iarg],"nchunk") == 0) { diff --git a/src/compute_chunk_spread_atom.cpp b/src/compute_chunk_spread_atom.cpp index 257e5d0960..d817141064 100644 --- a/src/compute_chunk_spread_atom.cpp +++ b/src/compute_chunk_spread_atom.cpp @@ -36,9 +36,7 @@ ComputeChunkSpreadAtom(LAMMPS *lmp, int narg, char **arg) : // ID of compute chunk/atom - int n = strlen(arg[3]) + 1; - idchunk = new char[n]; - strcpy(idchunk,arg[3]); + idchunk = utils::strdup(arg[3]); init_chunk(); // expand args if any have wildcard character "*" diff --git a/src/compute_com_chunk.cpp b/src/compute_com_chunk.cpp index 54b2354d26..a67b412b9e 100644 --- a/src/compute_com_chunk.cpp +++ b/src/compute_com_chunk.cpp @@ -43,9 +43,7 @@ ComputeCOMChunk::ComputeCOMChunk(LAMMPS *lmp, int narg, char **arg) : // ID of compute chunk/atom - int n = strlen(arg[3]) + 1; - idchunk = new char[n]; - strcpy(idchunk,arg[3]); + idchunk = utils::strdup(arg[3]); init(); diff --git a/src/compute_coord_atom.cpp b/src/compute_coord_atom.cpp index 51a3618d5a..1c56466b36 100644 --- a/src/compute_coord_atom.cpp +++ b/src/compute_coord_atom.cpp @@ -85,9 +85,7 @@ ComputeCoordAtom::ComputeCoordAtom(LAMMPS *lmp, int narg, char **arg) : cstyle = ORIENT; if (narg != 6) error->all(FLERR,"Illegal compute coord/atom command"); - int n = strlen(arg[4]) + 1; - id_orientorder = new char[n]; - strcpy(id_orientorder,arg[4]); + id_orientorder = utils::strdup(arg[4]); int iorientorder = modify->find_compute(id_orientorder); if (iorientorder < 0) diff --git a/src/compute_dihedral_local.cpp b/src/compute_dihedral_local.cpp index d6fa722e26..908acff98c 100644 --- a/src/compute_dihedral_local.cpp +++ b/src/compute_dihedral_local.cpp @@ -64,9 +64,7 @@ ComputeDihedralLocal::ComputeDihedralLocal(LAMMPS *lmp, int narg, char **arg) : bstyle[nvalues++] = PHI; } else if (strncmp(arg[iarg],"v_",2) == 0) { bstyle[nvalues++] = VARIABLE; - int n = strlen(arg[iarg]); - vstr[nvar] = new char[n]; - strcpy(vstr[nvar],&arg[iarg][2]); + vstr[nvar] = utils::strdup(&arg[iarg][2]); nvar++; } else break; } @@ -83,9 +81,7 @@ ComputeDihedralLocal::ComputeDihedralLocal(LAMMPS *lmp, int narg, char **arg) : error->all(FLERR,"Illegal compute dihedral/local command"); if (strcmp(arg[iarg+1],"phi") == 0) { delete [] pstr; - int n = strlen(arg[iarg+2]) + 1; - pstr = new char[n]; - strcpy(pstr,arg[iarg+2]); + pstr = utils::strdup(arg[iarg+2]); } else error->all(FLERR,"Illegal compute dihedral/local command"); iarg += 3; } else error->all(FLERR,"Illegal compute dihedral/local command"); diff --git a/src/compute_dipole_chunk.cpp b/src/compute_dipole_chunk.cpp index 540e533727..708ea3f755 100644 --- a/src/compute_dipole_chunk.cpp +++ b/src/compute_dipole_chunk.cpp @@ -49,9 +49,7 @@ ComputeDipoleChunk::ComputeDipoleChunk(LAMMPS *lmp, int narg, char **arg) : // ID of compute chunk/atom - int n = strlen(arg[3]) + 1; - idchunk = new char[n]; - strcpy(idchunk,arg[3]); + idchunk = utils::strdup(arg[3]); usecenter = MASSCENTER; diff --git a/src/compute_displace_atom.cpp b/src/compute_displace_atom.cpp index 445caa15dc..4e4b87f99c 100644 --- a/src/compute_displace_atom.cpp +++ b/src/compute_displace_atom.cpp @@ -53,9 +53,7 @@ ComputeDisplaceAtom::ComputeDisplaceAtom(LAMMPS *lmp, int narg, char **arg) : error->all(FLERR,"Illegal compute displace/atom command"); refreshflag = 1; delete [] rvar; - int n = strlen(arg[iarg+1]) + 1; - rvar = new char[n]; - strcpy(rvar,arg[iarg+1]); + rvar = utils::strdup(arg[iarg+1]); iarg += 2; } else error->all(FLERR,"Illegal compute displace/atom command"); } @@ -74,11 +72,9 @@ ComputeDisplaceAtom::ComputeDisplaceAtom(LAMMPS *lmp, int narg, char **arg) : // create a new fix STORE style // id = compute-ID + COMPUTE_STORE, fix group = compute group - std::string cmd = id + std::string("_COMPUTE_STORE"); - id_fix = new char[cmd.size()+1]; - strcpy(id_fix,cmd.c_str()); - - cmd += fmt::format(" {} STORE peratom 1 3", group->names[igroup]); + id_fix = utils::strdup(std::string(id) + "_COMPUTE_STORE"); + std::string cmd = id_fix + fmt::format(" {} STORE peratom 1 3", + group->names[igroup]); modify->add_fix(cmd); fix = (FixStore *) modify->fix[modify->nfix-1]; diff --git a/src/compute_group_group.cpp b/src/compute_group_group.cpp index be670332de..7912b4e031 100644 --- a/src/compute_group_group.cpp +++ b/src/compute_group_group.cpp @@ -54,10 +54,7 @@ ComputeGroupGroup::ComputeGroupGroup(LAMMPS *lmp, int narg, char **arg) : extscalar = 1; extvector = 1; - int n = strlen(arg[3]) + 1; - group2 = new char[n]; - strcpy(group2,arg[3]); - + group2 = utils::strdup(arg[3]); jgroup = group->find(group2); if (jgroup == -1) error->all(FLERR,"Compute group/group group ID does not exist"); diff --git a/src/compute_gyration_chunk.cpp b/src/compute_gyration_chunk.cpp index d2af181eaf..c2db9fa855 100644 --- a/src/compute_gyration_chunk.cpp +++ b/src/compute_gyration_chunk.cpp @@ -36,9 +36,7 @@ ComputeGyrationChunk::ComputeGyrationChunk(LAMMPS *lmp, int narg, char **arg) : // ID of compute chunk/atom - int n = strlen(arg[3]) + 1; - idchunk = new char[n]; - strcpy(idchunk,arg[3]); + idchunk = utils::strdup(arg[3]); init(); diff --git a/src/compute_heat_flux.cpp b/src/compute_heat_flux.cpp index 91019aef28..b2e5662a6b 100644 --- a/src/compute_heat_flux.cpp +++ b/src/compute_heat_flux.cpp @@ -43,17 +43,9 @@ ComputeHeatFlux::ComputeHeatFlux(LAMMPS *lmp, int narg, char **arg) : // store ke/atom, pe/atom, stress/atom IDs used by heat flux computation // insure they are valid for these computations - int n = strlen(arg[3]) + 1; - id_ke = new char[n]; - strcpy(id_ke,arg[3]); - - n = strlen(arg[4]) + 1; - id_pe = new char[n]; - strcpy(id_pe,arg[4]); - - n = strlen(arg[5]) + 1; - id_stress = new char[n]; - strcpy(id_stress,arg[5]); + id_ke = utils::strdup(arg[3]); + id_pe = utils::strdup(arg[4]); + id_stress = utils::strdup(arg[5]); int ike = modify->find_compute(id_ke); int ipe = modify->find_compute(id_pe); diff --git a/src/compute_inertia_chunk.cpp b/src/compute_inertia_chunk.cpp index d2c6d345ce..9e0084acfb 100644 --- a/src/compute_inertia_chunk.cpp +++ b/src/compute_inertia_chunk.cpp @@ -41,9 +41,7 @@ ComputeInertiaChunk::ComputeInertiaChunk(LAMMPS *lmp, int narg, char **arg) : // ID of compute chunk/atom - int n = strlen(arg[3]) + 1; - idchunk = new char[n]; - strcpy(idchunk,arg[3]); + idchunk = utils::strdup(arg[3]); init(); diff --git a/src/compute_msd_chunk.cpp b/src/compute_msd_chunk.cpp index 9dc3281b78..39ed9d1f1c 100644 --- a/src/compute_msd_chunk.cpp +++ b/src/compute_msd_chunk.cpp @@ -44,9 +44,7 @@ ComputeMSDChunk::ComputeMSDChunk(LAMMPS *lmp, int narg, char **arg) : // ID of compute chunk/atom - int n = strlen(arg[3]) + 1; - idchunk = new char[n]; - strcpy(idchunk,arg[3]); + idchunk = utils::strdup(arg[3]); firstflag = 1; init(); @@ -58,11 +56,9 @@ ComputeMSDChunk::ComputeMSDChunk(LAMMPS *lmp, int narg, char **arg) : // potentially re-populate the fix array (and change it to correct size) // otherwise size reset and init will be done in setup() - std::string fixcmd = id + std::string("_COMPUTE_STORE"); - id_fix = new char[fixcmd.size()+1]; - strcpy(id_fix,fixcmd.c_str()); - - fixcmd += fmt::format(" {} STORE global 1 1",group->names[igroup]); + id_fix = utils::strdup(std::string(id) + "_COMPUTE_STORE"); + std::string fixcmd = id_fix + + fmt::format(" {} STORE global 1 1",group->names[igroup]); modify->add_fix(fixcmd); fix = (FixStore *) modify->fix[modify->nfix-1]; } diff --git a/src/compute_omega_chunk.cpp b/src/compute_omega_chunk.cpp index b721f0efb5..da3b482341 100644 --- a/src/compute_omega_chunk.cpp +++ b/src/compute_omega_chunk.cpp @@ -45,9 +45,7 @@ ComputeOmegaChunk::ComputeOmegaChunk(LAMMPS *lmp, int narg, char **arg) : // ID of compute chunk/atom - int n = strlen(arg[3]) + 1; - idchunk = new char[n]; - strcpy(idchunk,arg[3]); + idchunk = utils::strdup(arg[3]); init(); diff --git a/src/compute_pair.cpp b/src/compute_pair.cpp index 4fd7de736d..aa9df260b1 100644 --- a/src/compute_pair.cpp +++ b/src/compute_pair.cpp @@ -37,10 +37,10 @@ ComputePair::ComputePair(LAMMPS *lmp, int narg, char **arg) : peflag = 1; timeflag = 1; - int n = strlen(arg[3]) + 1; - if (lmp->suffix) n += strlen(lmp->suffix) + 1; - pstyle = new char[n]; - strcpy(pstyle,arg[3]); + // copy with suffix so we can later chop it off, if needed + if (lmp->suffix) + pstyle = utils::strdup(fmt::format("{}/{}",arg[3],lmp->suffix)); + else pstyle = utils::strdup(arg[3]); int iarg = 4; nsub = 0; @@ -67,8 +67,7 @@ ComputePair::ComputePair(LAMMPS *lmp, int narg, char **arg) : pair = force->pair_match(pstyle,1,nsub); if (!pair && lmp->suffix) { - strcat(pstyle,"/"); - strcat(pstyle,lmp->suffix); + pstyle[strlen(pstyle) - strlen(lmp->suffix) - 1] = '\0'; pair = force->pair_match(pstyle,1,nsub); } diff --git a/src/compute_pressure.cpp b/src/compute_pressure.cpp index 82ddbbb5c5..3bf66f42ce 100644 --- a/src/compute_pressure.cpp +++ b/src/compute_pressure.cpp @@ -53,9 +53,7 @@ ComputePressure::ComputePressure(LAMMPS *lmp, int narg, char **arg) : if (strcmp(arg[3],"NULL") == 0) id_temp = nullptr; else { - int n = strlen(arg[3]) + 1; - id_temp = new char[n]; - strcpy(id_temp,arg[3]); + id_temp = utils::strdup(arg[3]); int icompute = modify->find_compute(id_temp); if (icompute < 0) @@ -82,10 +80,10 @@ ComputePressure::ComputePressure(LAMMPS *lmp, int narg, char **arg) : while (iarg < narg) { if (strcmp(arg[iarg],"ke") == 0) keflag = 1; else if (strcmp(arg[iarg],"pair/hybrid") == 0) { - int n = strlen(arg[++iarg]) + 1; - if (lmp->suffix) n += strlen(lmp->suffix) + 1; - pstyle = new char[n]; - strcpy(pstyle,arg[iarg++]); + if (lmp->suffix) + pstyle = utils::strdup(fmt::format("{}/{}",arg[++iarg],lmp->suffix)); + else + pstyle = utils::strdup(arg[++iarg]); nsub = 0; @@ -102,8 +100,7 @@ ComputePressure::ComputePressure(LAMMPS *lmp, int narg, char **arg) : pairhybrid = (Pair *) force->pair_match(pstyle,1,nsub); if (!pairhybrid && lmp->suffix) { - strcat(pstyle,"/"); - strcat(pstyle,lmp->suffix); + pstyle[strlen(pstyle) - strlen(lmp->suffix) - 1] = '\0'; pairhybrid = (Pair *) force->pair_match(pstyle,1,nsub); } diff --git a/src/compute_property_chunk.cpp b/src/compute_property_chunk.cpp index d1588b61a3..72e9831b0c 100644 --- a/src/compute_property_chunk.cpp +++ b/src/compute_property_chunk.cpp @@ -33,9 +33,7 @@ ComputePropertyChunk::ComputePropertyChunk(LAMMPS *lmp, int narg, char **arg) : // ID of compute chunk/atom - int n = strlen(arg[3]) + 1; - idchunk = new char[n]; - strcpy(idchunk,arg[3]); + idchunk = utils::strdup(arg[3]); init(); diff --git a/src/compute_reduce.cpp b/src/compute_reduce.cpp index bc9aeefe7b..30b4fcb98a 100644 --- a/src/compute_reduce.cpp +++ b/src/compute_reduce.cpp @@ -47,9 +47,7 @@ ComputeReduce::ComputeReduce(LAMMPS *lmp, int narg, char **arg) : iregion = domain->find_region(arg[3]); if (iregion == -1) error->all(FLERR,"Region ID for compute reduce/region does not exist"); - int n = strlen(arg[3]) + 1; - idregion = new char[n]; - strcpy(idregion,arg[3]); + idregion = utils::strdup(arg[3]); iarg = 4; } diff --git a/src/compute_reduce_chunk.cpp b/src/compute_reduce_chunk.cpp index a09d37b9d8..e895a13b18 100644 --- a/src/compute_reduce_chunk.cpp +++ b/src/compute_reduce_chunk.cpp @@ -45,9 +45,7 @@ ComputeReduceChunk::ComputeReduceChunk(LAMMPS *lmp, int narg, char **arg) : // ID of compute chunk/atom - int n = strlen(arg[3]) + 1; - idchunk = new char[n]; - strcpy(idchunk,arg[3]); + idchunk = utils::strdup(arg[3]); init_chunk(); // mode diff --git a/src/compute_stress_atom.cpp b/src/compute_stress_atom.cpp index 28abc13453..0d27031326 100644 --- a/src/compute_stress_atom.cpp +++ b/src/compute_stress_atom.cpp @@ -51,9 +51,7 @@ ComputeStressAtom::ComputeStressAtom(LAMMPS *lmp, int narg, char **arg) : if (strcmp(arg[3],"NULL") == 0) id_temp = nullptr; else { - int n = strlen(arg[3]) + 1; - id_temp = new char[n]; - strcpy(id_temp,arg[3]); + id_temp = utils::strdup(arg[3]); int icompute = modify->find_compute(id_temp); if (icompute < 0) diff --git a/src/compute_temp_chunk.cpp b/src/compute_temp_chunk.cpp index 765effa6c0..31f955fcb5 100644 --- a/src/compute_temp_chunk.cpp +++ b/src/compute_temp_chunk.cpp @@ -44,9 +44,7 @@ ComputeTempChunk::ComputeTempChunk(LAMMPS *lmp, int narg, char **arg) : // ID of compute chunk/atom - int n = strlen(arg[3]) + 1; - idchunk = new char[n]; - strcpy(idchunk,arg[3]); + idchunk = utils::strdup(arg[3]); biasflag = 0; init(); @@ -87,9 +85,7 @@ ComputeTempChunk::ComputeTempChunk(LAMMPS *lmp, int narg, char **arg) : if (iarg+2 > narg) error->all(FLERR,"Illegal compute temp/chunk command"); biasflag = 1; - int n = strlen(arg[iarg+1]) + 1; - id_bias = new char[n]; - strcpy(id_bias,arg[iarg+1]); + id_bias = utils::strdup(arg[iarg+1]); iarg += 2; } else if (strcmp(arg[iarg],"adof") == 0) { if (iarg+2 > narg) diff --git a/src/compute_temp_region.cpp b/src/compute_temp_region.cpp index e1ce4e024b..036f118a30 100644 --- a/src/compute_temp_region.cpp +++ b/src/compute_temp_region.cpp @@ -36,9 +36,7 @@ ComputeTempRegion::ComputeTempRegion(LAMMPS *lmp, int narg, char **arg) : iregion = domain->find_region(arg[3]); if (iregion == -1) error->all(FLERR,"Region ID for compute temp/region does not exist"); - int n = strlen(arg[3]) + 1; - idregion = new char[n]; - strcpy(idregion,arg[3]); + idregion = utils::strdup(arg[3]); scalar_flag = vector_flag = 1; size_vector = 6; diff --git a/src/compute_temp_sphere.cpp b/src/compute_temp_sphere.cpp index 8ffb1b2d6f..b8ac7cf566 100644 --- a/src/compute_temp_sphere.cpp +++ b/src/compute_temp_sphere.cpp @@ -51,9 +51,7 @@ ComputeTempSphere::ComputeTempSphere(LAMMPS *lmp, int narg, char **arg) : if (iarg+2 > narg) error->all(FLERR,"Illegal compute temp/sphere command"); tempbias = 1; - int n = strlen(arg[iarg+1]) + 1; - id_bias = new char[n]; - strcpy(id_bias,arg[iarg+1]); + id_bias = utils::strdup(arg[iarg+1]); iarg += 2; } else if (strcmp(arg[iarg],"dof") == 0) { if (iarg+2 > narg) diff --git a/src/compute_torque_chunk.cpp b/src/compute_torque_chunk.cpp index d961c914e8..9aea024114 100644 --- a/src/compute_torque_chunk.cpp +++ b/src/compute_torque_chunk.cpp @@ -40,9 +40,7 @@ ComputeTorqueChunk::ComputeTorqueChunk(LAMMPS *lmp, int narg, char **arg) : // ID of compute chunk/atom - int n = strlen(arg[3]) + 1; - idchunk = new char[n]; - strcpy(idchunk,arg[3]); + idchunk = utils::strdup(arg[3]); init(); diff --git a/src/compute_vcm_chunk.cpp b/src/compute_vcm_chunk.cpp index 182e8191cb..dd4bac208f 100644 --- a/src/compute_vcm_chunk.cpp +++ b/src/compute_vcm_chunk.cpp @@ -41,9 +41,7 @@ ComputeVCMChunk::ComputeVCMChunk(LAMMPS *lmp, int narg, char **arg) : // ID of compute chunk/atom - int n = strlen(arg[3]) + 1; - idchunk = new char[n]; - strcpy(idchunk,arg[3]); + idchunk = utils::strdup(arg[3]); init();