Adopt utils::strdup in dump styles
This commit is contained in:
@ -77,14 +77,12 @@ void DumpAtomGZ::openfile()
|
|||||||
*ptr = '*';
|
*ptr = '*';
|
||||||
if (maxfiles > 0) {
|
if (maxfiles > 0) {
|
||||||
if (numfiles < maxfiles) {
|
if (numfiles < maxfiles) {
|
||||||
nameslist[numfiles] = new char[strlen(filecurrent)+1];
|
nameslist[numfiles] = utils::strdup(filecurrent);
|
||||||
strcpy(nameslist[numfiles],filecurrent);
|
|
||||||
++numfiles;
|
++numfiles;
|
||||||
} else {
|
} else {
|
||||||
remove(nameslist[fileidx]);
|
remove(nameslist[fileidx]);
|
||||||
delete[] nameslist[fileidx];
|
delete[] nameslist[fileidx];
|
||||||
nameslist[fileidx] = new char[strlen(filecurrent)+1];
|
nameslist[fileidx] = utils::strdup(filecurrent);
|
||||||
strcpy(nameslist[fileidx],filecurrent);
|
|
||||||
fileidx = (fileidx + 1) % maxfiles;
|
fileidx = (fileidx + 1) % maxfiles;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -76,14 +76,12 @@ void DumpAtomZstd::openfile()
|
|||||||
*ptr = '*';
|
*ptr = '*';
|
||||||
if (maxfiles > 0) {
|
if (maxfiles > 0) {
|
||||||
if (numfiles < maxfiles) {
|
if (numfiles < maxfiles) {
|
||||||
nameslist[numfiles] = new char[strlen(filecurrent)+1];
|
nameslist[numfiles] = utils::strdup(filecurrent);
|
||||||
strcpy(nameslist[numfiles],filecurrent);
|
|
||||||
++numfiles;
|
++numfiles;
|
||||||
} else {
|
} else {
|
||||||
remove(nameslist[fileidx]);
|
remove(nameslist[fileidx]);
|
||||||
delete[] nameslist[fileidx];
|
delete[] nameslist[fileidx];
|
||||||
nameslist[fileidx] = new char[strlen(filecurrent)+1];
|
nameslist[fileidx] = utils::strdup(filecurrent);
|
||||||
strcpy(nameslist[fileidx],filecurrent);
|
|
||||||
fileidx = (fileidx + 1) % maxfiles;
|
fileidx = (fileidx + 1) % maxfiles;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -81,14 +81,12 @@ void DumpCFGGZ::openfile()
|
|||||||
*ptr = '*';
|
*ptr = '*';
|
||||||
if (maxfiles > 0) {
|
if (maxfiles > 0) {
|
||||||
if (numfiles < maxfiles) {
|
if (numfiles < maxfiles) {
|
||||||
nameslist[numfiles] = new char[strlen(filecurrent)+1];
|
nameslist[numfiles] = utils::strdup(filecurrent);
|
||||||
strcpy(nameslist[numfiles],filecurrent);
|
|
||||||
++numfiles;
|
++numfiles;
|
||||||
} else {
|
} else {
|
||||||
remove(nameslist[fileidx]);
|
remove(nameslist[fileidx]);
|
||||||
delete[] nameslist[fileidx];
|
delete[] nameslist[fileidx];
|
||||||
nameslist[fileidx] = new char[strlen(filecurrent)+1];
|
nameslist[fileidx] = utils::strdup(filecurrent);
|
||||||
strcpy(nameslist[fileidx],filecurrent);
|
|
||||||
fileidx = (fileidx + 1) % maxfiles;
|
fileidx = (fileidx + 1) % maxfiles;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -79,14 +79,12 @@ void DumpCFGZstd::openfile()
|
|||||||
*ptr = '*';
|
*ptr = '*';
|
||||||
if (maxfiles > 0) {
|
if (maxfiles > 0) {
|
||||||
if (numfiles < maxfiles) {
|
if (numfiles < maxfiles) {
|
||||||
nameslist[numfiles] = new char[strlen(filecurrent)+1];
|
nameslist[numfiles] = utils::strdup(filecurrent);
|
||||||
strcpy(nameslist[numfiles],filecurrent);
|
|
||||||
++numfiles;
|
++numfiles;
|
||||||
} else {
|
} else {
|
||||||
remove(nameslist[fileidx]);
|
remove(nameslist[fileidx]);
|
||||||
delete[] nameslist[fileidx];
|
delete[] nameslist[fileidx];
|
||||||
nameslist[fileidx] = new char[strlen(filecurrent)+1];
|
nameslist[fileidx] = utils::strdup(filecurrent);
|
||||||
strcpy(nameslist[fileidx],filecurrent);
|
|
||||||
fileidx = (fileidx + 1) % maxfiles;
|
fileidx = (fileidx + 1) % maxfiles;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -79,14 +79,12 @@ void DumpCustomGZ::openfile()
|
|||||||
*ptr = '*';
|
*ptr = '*';
|
||||||
if (maxfiles > 0) {
|
if (maxfiles > 0) {
|
||||||
if (numfiles < maxfiles) {
|
if (numfiles < maxfiles) {
|
||||||
nameslist[numfiles] = new char[strlen(filecurrent)+1];
|
nameslist[numfiles] = utils::strdup(filecurrent);
|
||||||
strcpy(nameslist[numfiles],filecurrent);
|
|
||||||
++numfiles;
|
++numfiles;
|
||||||
} else {
|
} else {
|
||||||
remove(nameslist[fileidx]);
|
remove(nameslist[fileidx]);
|
||||||
delete[] nameslist[fileidx];
|
delete[] nameslist[fileidx];
|
||||||
nameslist[fileidx] = new char[strlen(filecurrent)+1];
|
nameslist[fileidx] = utils::strdup(filecurrent);
|
||||||
strcpy(nameslist[fileidx],filecurrent);
|
|
||||||
fileidx = (fileidx + 1) % maxfiles;
|
fileidx = (fileidx + 1) % maxfiles;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -76,14 +76,12 @@ void DumpCustomZstd::openfile()
|
|||||||
*ptr = '*';
|
*ptr = '*';
|
||||||
if (maxfiles > 0) {
|
if (maxfiles > 0) {
|
||||||
if (numfiles < maxfiles) {
|
if (numfiles < maxfiles) {
|
||||||
nameslist[numfiles] = new char[strlen(filecurrent)+1];
|
nameslist[numfiles] = utils::strdup(filecurrent);
|
||||||
strcpy(nameslist[numfiles],filecurrent);
|
|
||||||
++numfiles;
|
++numfiles;
|
||||||
} else {
|
} else {
|
||||||
remove(nameslist[fileidx]);
|
remove(nameslist[fileidx]);
|
||||||
delete[] nameslist[fileidx];
|
delete[] nameslist[fileidx];
|
||||||
nameslist[fileidx] = new char[strlen(filecurrent)+1];
|
nameslist[fileidx] = utils::strdup(filecurrent);
|
||||||
strcpy(nameslist[fileidx],filecurrent);
|
|
||||||
fileidx = (fileidx + 1) % maxfiles;
|
fileidx = (fileidx + 1) % maxfiles;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -79,14 +79,12 @@ void DumpLocalGZ::openfile()
|
|||||||
*ptr = '*';
|
*ptr = '*';
|
||||||
if (maxfiles > 0) {
|
if (maxfiles > 0) {
|
||||||
if (numfiles < maxfiles) {
|
if (numfiles < maxfiles) {
|
||||||
nameslist[numfiles] = new char[strlen(filecurrent)+1];
|
nameslist[numfiles] = utils::strdup(filecurrent);
|
||||||
strcpy(nameslist[numfiles],filecurrent);
|
|
||||||
++numfiles;
|
++numfiles;
|
||||||
} else {
|
} else {
|
||||||
remove(nameslist[fileidx]);
|
remove(nameslist[fileidx]);
|
||||||
delete[] nameslist[fileidx];
|
delete[] nameslist[fileidx];
|
||||||
nameslist[fileidx] = new char[strlen(filecurrent)+1];
|
nameslist[fileidx] = utils::strdup(filecurrent);
|
||||||
strcpy(nameslist[fileidx],filecurrent);
|
|
||||||
fileidx = (fileidx + 1) % maxfiles;
|
fileidx = (fileidx + 1) % maxfiles;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -78,14 +78,12 @@ void DumpLocalZstd::openfile()
|
|||||||
*ptr = '*';
|
*ptr = '*';
|
||||||
if (maxfiles > 0) {
|
if (maxfiles > 0) {
|
||||||
if (numfiles < maxfiles) {
|
if (numfiles < maxfiles) {
|
||||||
nameslist[numfiles] = new char[strlen(filecurrent)+1];
|
nameslist[numfiles] = utils::strdup(filecurrent);
|
||||||
strcpy(nameslist[numfiles],filecurrent);
|
|
||||||
++numfiles;
|
++numfiles;
|
||||||
} else {
|
} else {
|
||||||
remove(nameslist[fileidx]);
|
remove(nameslist[fileidx]);
|
||||||
delete[] nameslist[fileidx];
|
delete[] nameslist[fileidx];
|
||||||
nameslist[fileidx] = new char[strlen(filecurrent)+1];
|
nameslist[fileidx] = utils::strdup(filecurrent);
|
||||||
strcpy(nameslist[fileidx],filecurrent);
|
|
||||||
fileidx = (fileidx + 1) % maxfiles;
|
fileidx = (fileidx + 1) % maxfiles;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -78,14 +78,12 @@ void DumpXYZGZ::openfile()
|
|||||||
*ptr = '*';
|
*ptr = '*';
|
||||||
if (maxfiles > 0) {
|
if (maxfiles > 0) {
|
||||||
if (numfiles < maxfiles) {
|
if (numfiles < maxfiles) {
|
||||||
nameslist[numfiles] = new char[strlen(filecurrent)+1];
|
nameslist[numfiles] = utils::strdup(filecurrent);
|
||||||
strcpy(nameslist[numfiles],filecurrent);
|
|
||||||
++numfiles;
|
++numfiles;
|
||||||
} else {
|
} else {
|
||||||
remove(nameslist[fileidx]);
|
remove(nameslist[fileidx]);
|
||||||
delete[] nameslist[fileidx];
|
delete[] nameslist[fileidx];
|
||||||
nameslist[fileidx] = new char[strlen(filecurrent)+1];
|
nameslist[fileidx] = utils::strdup(filecurrent);
|
||||||
strcpy(nameslist[fileidx],filecurrent);
|
|
||||||
fileidx = (fileidx + 1) % maxfiles;
|
fileidx = (fileidx + 1) % maxfiles;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -76,14 +76,12 @@ void DumpXYZZstd::openfile()
|
|||||||
*ptr = '*';
|
*ptr = '*';
|
||||||
if (maxfiles > 0) {
|
if (maxfiles > 0) {
|
||||||
if (numfiles < maxfiles) {
|
if (numfiles < maxfiles) {
|
||||||
nameslist[numfiles] = new char[strlen(filecurrent)+1];
|
nameslist[numfiles] = utils::strdup(filecurrent);
|
||||||
strcpy(nameslist[numfiles],filecurrent);
|
|
||||||
++numfiles;
|
++numfiles;
|
||||||
} else {
|
} else {
|
||||||
remove(nameslist[fileidx]);
|
remove(nameslist[fileidx]);
|
||||||
delete[] nameslist[fileidx];
|
delete[] nameslist[fileidx];
|
||||||
nameslist[fileidx] = new char[strlen(filecurrent)+1];
|
nameslist[fileidx] = utils::strdup(filecurrent);
|
||||||
strcpy(nameslist[fileidx],filecurrent);
|
|
||||||
fileidx = (fileidx + 1) % maxfiles;
|
fileidx = (fileidx + 1) % maxfiles;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
35
src/dump.cpp
35
src/dump.cpp
@ -46,20 +46,14 @@ Dump::Dump(LAMMPS *lmp, int /*narg*/, char **arg) : Pointers(lmp)
|
|||||||
MPI_Comm_rank(world,&me);
|
MPI_Comm_rank(world,&me);
|
||||||
MPI_Comm_size(world,&nprocs);
|
MPI_Comm_size(world,&nprocs);
|
||||||
|
|
||||||
int n = strlen(arg[0]) + 1;
|
id = utils::strdup(arg[0]);
|
||||||
id = new char[n];
|
|
||||||
strcpy(id,arg[0]);
|
|
||||||
|
|
||||||
igroup = group->find(arg[1]);
|
igroup = group->find(arg[1]);
|
||||||
groupbit = group->bitmask[igroup];
|
groupbit = group->bitmask[igroup];
|
||||||
|
|
||||||
n = strlen(arg[2]) + 1;
|
style = utils::strdup(arg[2]);
|
||||||
style = new char[n];
|
|
||||||
strcpy(style,arg[2]);
|
|
||||||
|
|
||||||
n = strlen(arg[4]) + 1;
|
filename = utils::strdup(arg[4]);
|
||||||
filename = new char[n];
|
|
||||||
strcpy(filename,arg[4]);
|
|
||||||
|
|
||||||
comm_forward = comm_reverse = 0;
|
comm_forward = comm_reverse = 0;
|
||||||
|
|
||||||
@ -140,9 +134,8 @@ Dump::Dump(LAMMPS *lmp, int /*narg*/, char **arg) : Pointers(lmp)
|
|||||||
filewriter = 1;
|
filewriter = 1;
|
||||||
fileproc = me;
|
fileproc = me;
|
||||||
MPI_Comm_split(world,me,0,&clustercomm);
|
MPI_Comm_split(world,me,0,&clustercomm);
|
||||||
multiname = new char[strlen(filename) + 16];
|
|
||||||
*ptr = '\0';
|
*ptr = '\0';
|
||||||
sprintf(multiname,"%s%d%s",filename,me,ptr+1);
|
multiname = utils::strdup(fmt::format("{}{}{}", filename, me, ptr+1));
|
||||||
*ptr = '%';
|
*ptr = '%';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -573,14 +566,12 @@ void Dump::openfile()
|
|||||||
*ptr = '*';
|
*ptr = '*';
|
||||||
if (maxfiles > 0) {
|
if (maxfiles > 0) {
|
||||||
if (numfiles < maxfiles) {
|
if (numfiles < maxfiles) {
|
||||||
nameslist[numfiles] = new char[strlen(filecurrent)+1];
|
nameslist[numfiles] = utils::strdup(filecurrent);
|
||||||
strcpy(nameslist[numfiles],filecurrent);
|
|
||||||
++numfiles;
|
++numfiles;
|
||||||
} else {
|
} else {
|
||||||
remove(nameslist[fileidx]);
|
remove(nameslist[fileidx]);
|
||||||
delete[] nameslist[fileidx];
|
delete[] nameslist[fileidx];
|
||||||
nameslist[fileidx] = new char[strlen(filecurrent)+1];
|
nameslist[fileidx] = utils::strdup(filecurrent);
|
||||||
strcpy(nameslist[fileidx],filecurrent);
|
|
||||||
fileidx = (fileidx + 1) % maxfiles;
|
fileidx = (fileidx + 1) % maxfiles;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -952,9 +943,7 @@ void Dump::modify_params(int narg, char **arg)
|
|||||||
int n;
|
int n;
|
||||||
if (strstr(arg[iarg+1],"v_") == arg[iarg+1]) {
|
if (strstr(arg[iarg+1],"v_") == arg[iarg+1]) {
|
||||||
delete [] output->var_dump[idump];
|
delete [] output->var_dump[idump];
|
||||||
n = strlen(&arg[iarg+1][2]) + 1;
|
output->var_dump[idump] = utils::strdup(&arg[iarg+1][2]);
|
||||||
output->var_dump[idump] = new char[n];
|
|
||||||
strcpy(output->var_dump[idump],&arg[iarg+1][2]);
|
|
||||||
n = 0;
|
n = 0;
|
||||||
} else {
|
} else {
|
||||||
n = utils::inumeric(FLERR,arg[iarg+1],false,lmp);
|
n = utils::inumeric(FLERR,arg[iarg+1],false,lmp);
|
||||||
@ -984,10 +973,9 @@ void Dump::modify_params(int narg, char **arg)
|
|||||||
MPI_Comm_split(world,icluster,0,&clustercomm);
|
MPI_Comm_split(world,icluster,0,&clustercomm);
|
||||||
|
|
||||||
delete [] multiname;
|
delete [] multiname;
|
||||||
multiname = new char[strlen(filename) + 16];
|
|
||||||
char *ptr = strchr(filename,'%');
|
char *ptr = strchr(filename,'%');
|
||||||
*ptr = '\0';
|
*ptr = '\0';
|
||||||
sprintf(multiname,"%s%d%s",filename,icluster,ptr+1);
|
multiname = utils::strdup(fmt::format("{}{}{}", filename, icluster, ptr+1));
|
||||||
*ptr = '%';
|
*ptr = '%';
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
|
|
||||||
@ -1028,9 +1016,7 @@ void Dump::modify_params(int narg, char **arg)
|
|||||||
|
|
||||||
if (strcmp(arg[iarg+1],"line") == 0) {
|
if (strcmp(arg[iarg+1],"line") == 0) {
|
||||||
delete [] format_line_user;
|
delete [] format_line_user;
|
||||||
int n = strlen(arg[iarg+2]) + 1;
|
format_line_user = utils::strdup(arg[iarg+2]);
|
||||||
format_line_user = new char[n];
|
|
||||||
strcpy(format_line_user,arg[iarg+2]);
|
|
||||||
iarg += 3;
|
iarg += 3;
|
||||||
} else { // pass other format options to child classes
|
} else { // pass other format options to child classes
|
||||||
int n = modify_param(narg-iarg,&arg[iarg]);
|
int n = modify_param(narg-iarg,&arg[iarg]);
|
||||||
@ -1085,10 +1071,9 @@ void Dump::modify_params(int narg, char **arg)
|
|||||||
MPI_Comm_split(world,icluster,0,&clustercomm);
|
MPI_Comm_split(world,icluster,0,&clustercomm);
|
||||||
|
|
||||||
delete [] multiname;
|
delete [] multiname;
|
||||||
multiname = new char[strlen(filename) + 16];
|
|
||||||
char *ptr = strchr(filename,'%');
|
char *ptr = strchr(filename,'%');
|
||||||
*ptr = '\0';
|
*ptr = '\0';
|
||||||
sprintf(multiname,"%s%d%s",filename,icluster,ptr+1);
|
multiname = utils::strdup(fmt::format("{}{}{}", filename, icluster, ptr+1));
|
||||||
*ptr = '%';
|
*ptr = '%';
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
|
|
||||||
|
|||||||
@ -74,14 +74,10 @@ DumpCFG::DumpCFG(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
|ArgInfo::DNAME|ArgInfo::INAME);
|
|ArgInfo::DNAME|ArgInfo::INAME);
|
||||||
|
|
||||||
if (argi.get_dim() == 1) {
|
if (argi.get_dim() == 1) {
|
||||||
std::string newarg(std::to_string(earg[iarg][0]));
|
std::string newarg = fmt::format("{}_{}_{}", earg[iarg][0], argi.get_name(), argi.get_index1());
|
||||||
newarg += std::string("_") + argi.get_name();
|
auxname[i] = utils::strdup(newarg);
|
||||||
newarg += std::string("_") + std::to_string(argi.get_index1());
|
|
||||||
auxname[i] = new char[newarg.size()+1];
|
|
||||||
strcpy(auxname[i],newarg.c_str());
|
|
||||||
} else {
|
} else {
|
||||||
auxname[i] = new char[strlen(earg[iarg]) + 1];
|
auxname[i] = utils::strdup(earg[iarg]);
|
||||||
strcpy(auxname[i],earg[iarg]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1562,9 +1562,7 @@ int DumpCustom::add_compute(const char *id)
|
|||||||
delete [] compute;
|
delete [] compute;
|
||||||
compute = new Compute*[ncompute+1];
|
compute = new Compute*[ncompute+1];
|
||||||
|
|
||||||
int n = strlen(id) + 1;
|
id_compute[ncompute] = utils::strdup(id);
|
||||||
id_compute[ncompute] = new char[n];
|
|
||||||
strcpy(id_compute[ncompute],id);
|
|
||||||
ncompute++;
|
ncompute++;
|
||||||
return ncompute-1;
|
return ncompute-1;
|
||||||
}
|
}
|
||||||
@ -1587,9 +1585,7 @@ int DumpCustom::add_fix(const char *id)
|
|||||||
delete [] fix;
|
delete [] fix;
|
||||||
fix = new Fix*[nfix+1];
|
fix = new Fix*[nfix+1];
|
||||||
|
|
||||||
int n = strlen(id) + 1;
|
id_fix[nfix] = utils::strdup(id);
|
||||||
id_fix[nfix] = new char[n];
|
|
||||||
strcpy(id_fix[nfix],id);
|
|
||||||
nfix++;
|
nfix++;
|
||||||
return nfix-1;
|
return nfix-1;
|
||||||
}
|
}
|
||||||
@ -1616,9 +1612,7 @@ int DumpCustom::add_variable(const char *id)
|
|||||||
vbuf = new double*[nvariable+1];
|
vbuf = new double*[nvariable+1];
|
||||||
for (int i = 0; i <= nvariable; i++) vbuf[i] = nullptr;
|
for (int i = 0; i <= nvariable; i++) vbuf[i] = nullptr;
|
||||||
|
|
||||||
int n = strlen(id) + 1;
|
id_variable[nvariable] = utils::strdup(id);
|
||||||
id_variable[nvariable] = new char[n];
|
|
||||||
strcpy(id_variable[nvariable],id);
|
|
||||||
nvariable++;
|
nvariable++;
|
||||||
return nvariable-1;
|
return nvariable-1;
|
||||||
}
|
}
|
||||||
@ -1642,9 +1636,7 @@ int DumpCustom::add_custom(const char *id, int flag)
|
|||||||
flag_custom = (int *)
|
flag_custom = (int *)
|
||||||
memory->srealloc(flag_custom,(ncustom+1)*sizeof(int),"dump:flag_custom");
|
memory->srealloc(flag_custom,(ncustom+1)*sizeof(int),"dump:flag_custom");
|
||||||
|
|
||||||
int n = strlen(id) + 1;
|
id_custom[ncustom] = utils::strdup(id);
|
||||||
id_custom[ncustom] = new char[n];
|
|
||||||
strcpy(id_custom[ncustom],id);
|
|
||||||
flag_custom[ncustom] = flag;
|
flag_custom[ncustom] = flag;
|
||||||
|
|
||||||
ncustom++;
|
ncustom++;
|
||||||
@ -1663,9 +1655,7 @@ int DumpCustom::modify_param(int narg, char **arg)
|
|||||||
if (iregion == -1)
|
if (iregion == -1)
|
||||||
error->all(FLERR,"Dump_modify region ID does not exist");
|
error->all(FLERR,"Dump_modify region ID does not exist");
|
||||||
delete [] idregion;
|
delete [] idregion;
|
||||||
int n = strlen(arg[1]) + 1;
|
idregion = utils::strdup(arg[1]);
|
||||||
idregion = new char[n];
|
|
||||||
strcpy(idregion,arg[1]);
|
|
||||||
}
|
}
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
@ -1686,11 +1676,9 @@ int DumpCustom::modify_param(int narg, char **arg)
|
|||||||
|
|
||||||
if (strcmp(arg[1],"int") == 0) {
|
if (strcmp(arg[1],"int") == 0) {
|
||||||
delete [] format_int_user;
|
delete [] format_int_user;
|
||||||
int n = strlen(arg[2]) + 1;
|
format_int_user = utils::strdup(arg[2]);
|
||||||
format_int_user = new char[n];
|
|
||||||
strcpy(format_int_user,arg[2]);
|
|
||||||
delete [] format_bigint_user;
|
delete [] format_bigint_user;
|
||||||
n = strlen(format_int_user) + 8;
|
int n = strlen(format_int_user) + 8;
|
||||||
format_bigint_user = new char[n];
|
format_bigint_user = new char[n];
|
||||||
// replace "d" in format_int_user with bigint format specifier
|
// replace "d" in format_int_user with bigint format specifier
|
||||||
// use of &str[1] removes leading '%' from BIGINT_FORMAT string
|
// use of &str[1] removes leading '%' from BIGINT_FORMAT string
|
||||||
@ -1706,18 +1694,14 @@ int DumpCustom::modify_param(int narg, char **arg)
|
|||||||
|
|
||||||
} else if (strcmp(arg[1],"float") == 0) {
|
} else if (strcmp(arg[1],"float") == 0) {
|
||||||
delete [] format_float_user;
|
delete [] format_float_user;
|
||||||
int n = strlen(arg[2]) + 1;
|
format_float_user = utils::strdup(arg[2]);
|
||||||
format_float_user = new char[n];
|
|
||||||
strcpy(format_float_user,arg[2]);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
int i = utils::inumeric(FLERR,arg[1],false,lmp) - 1;
|
int i = utils::inumeric(FLERR,arg[1],false,lmp) - 1;
|
||||||
if (i < 0 || i >= nfield)
|
if (i < 0 || i >= nfield)
|
||||||
error->all(FLERR,"Illegal dump_modify command");
|
error->all(FLERR,"Illegal dump_modify command");
|
||||||
if (format_column_user[i]) delete [] format_column_user[i];
|
if (format_column_user[i]) delete [] format_column_user[i];
|
||||||
int n = strlen(arg[2]) + 1;
|
format_column_user[i] = utils::strdup(arg[2]);
|
||||||
format_column_user[i] = new char[n];
|
|
||||||
strcpy(format_column_user[i],arg[2]);
|
|
||||||
}
|
}
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
@ -1730,9 +1714,7 @@ int DumpCustom::modify_param(int narg, char **arg)
|
|||||||
delete [] typenames;
|
delete [] typenames;
|
||||||
typenames = new char*[ntypes+1];
|
typenames = new char*[ntypes+1];
|
||||||
for (int itype = 1; itype <= ntypes; itype++) {
|
for (int itype = 1; itype <= ntypes; itype++) {
|
||||||
int n = strlen(arg[itype]) + 1;
|
typenames[itype] = utils::strdup(arg[itype]);
|
||||||
typenames[itype] = new char[n];
|
|
||||||
strcpy(typenames[itype],arg[itype]);
|
|
||||||
}
|
}
|
||||||
return ntypes+1;
|
return ntypes+1;
|
||||||
}
|
}
|
||||||
@ -1998,8 +1980,7 @@ int DumpCustom::modify_param(int narg, char **arg)
|
|||||||
memory->grow(thresh_first,(nthreshlast+1),"dump:thresh_first");
|
memory->grow(thresh_first,(nthreshlast+1),"dump:thresh_first");
|
||||||
|
|
||||||
std::string threshid = fmt::format("{}{}_DUMP_STORE",id,nthreshlast);
|
std::string threshid = fmt::format("{}{}_DUMP_STORE",id,nthreshlast);
|
||||||
thresh_fixID[nthreshlast] = new char[threshid.size()+1];
|
thresh_fixID[nthreshlast] = utils::strdup(threshid);
|
||||||
strcpy(thresh_fixID[nthreshlast],threshid.c_str());
|
|
||||||
modify->add_fix(fmt::format("{} {} STORE peratom 1 1",threshid,
|
modify->add_fix(fmt::format("{} {} STORE peratom 1 1",threshid,
|
||||||
group->names[igroup]));
|
group->names[igroup]));
|
||||||
thresh_fix[nthreshlast] = (FixStore *) modify->fix[modify->nfix-1];
|
thresh_fix[nthreshlast] = (FixStore *) modify->fix[modify->nfix-1];
|
||||||
|
|||||||
@ -472,9 +472,7 @@ int DumpLocal::add_compute(const char *id)
|
|||||||
delete [] compute;
|
delete [] compute;
|
||||||
compute = new Compute*[ncompute+1];
|
compute = new Compute*[ncompute+1];
|
||||||
|
|
||||||
int n = strlen(id) + 1;
|
id_compute[ncompute] = utils::strdup(id);
|
||||||
id_compute[ncompute] = new char[n];
|
|
||||||
strcpy(id_compute[ncompute],id);
|
|
||||||
ncompute++;
|
ncompute++;
|
||||||
return ncompute-1;
|
return ncompute-1;
|
||||||
}
|
}
|
||||||
@ -497,9 +495,7 @@ int DumpLocal::add_fix(const char *id)
|
|||||||
delete [] fix;
|
delete [] fix;
|
||||||
fix = new Fix*[nfix+1];
|
fix = new Fix*[nfix+1];
|
||||||
|
|
||||||
int n = strlen(id) + 1;
|
id_fix[nfix] = utils::strdup(id);
|
||||||
id_fix[nfix] = new char[n];
|
|
||||||
strcpy(id_fix[nfix],id);
|
|
||||||
nfix++;
|
nfix++;
|
||||||
return nfix-1;
|
return nfix-1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,10 +40,7 @@ DumpXYZ::DumpXYZ(LAMMPS *lmp, int narg, char **arg) : Dump(lmp, narg, arg),
|
|||||||
|
|
||||||
if (format_default) delete [] format_default;
|
if (format_default) delete [] format_default;
|
||||||
|
|
||||||
char *str = (char *) "%s %g %g %g";
|
format_default = utils::strdup("%s %g %g %g");
|
||||||
int n = strlen(str) + 1;
|
|
||||||
format_default = new char[n];
|
|
||||||
strcpy(format_default,str);
|
|
||||||
|
|
||||||
ntypes = atom->ntypes;
|
ntypes = atom->ntypes;
|
||||||
typenames = nullptr;
|
typenames = nullptr;
|
||||||
@ -71,14 +68,11 @@ void DumpXYZ::init_style()
|
|||||||
// format = copy of default or user-specified line format
|
// format = copy of default or user-specified line format
|
||||||
|
|
||||||
delete [] format;
|
delete [] format;
|
||||||
char *str;
|
|
||||||
if (format_line_user) str = format_line_user;
|
|
||||||
else str = format_default;
|
|
||||||
|
|
||||||
int n = strlen(str) + 2;
|
if (format_line_user)
|
||||||
format = new char[n];
|
format = utils::strdup(fmt::format("{}\n", format_line_user));
|
||||||
strcpy(format,str);
|
else
|
||||||
strcat(format,"\n");
|
format = utils::strdup(fmt::format("{}\n", format_default));
|
||||||
|
|
||||||
// initialize typenames array to be backward compatible by default
|
// initialize typenames array to be backward compatible by default
|
||||||
// a 32-bit int can be maximally 10 digits plus sign
|
// a 32-bit int can be maximally 10 digits plus sign
|
||||||
@ -119,9 +113,7 @@ int DumpXYZ::modify_param(int narg, char **arg)
|
|||||||
|
|
||||||
typenames = new char*[ntypes+1];
|
typenames = new char*[ntypes+1];
|
||||||
for (int itype = 1; itype <= ntypes; itype++) {
|
for (int itype = 1; itype <= ntypes; itype++) {
|
||||||
int n = strlen(arg[itype]) + 1;
|
typenames[itype] = utils::strdup(arg[itype]);
|
||||||
typenames[itype] = new char[n];
|
|
||||||
strcpy(typenames[itype],arg[itype]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ntypes+1;
|
return ntypes+1;
|
||||||
|
|||||||
Reference in New Issue
Block a user