no local buffers and snprintf() in a bunch of style creation functions

This commit is contained in:
Axel Kohlmeyer
2020-06-04 14:36:56 -04:00
parent 481d3cb219
commit b27ef02bc2
3 changed files with 79 additions and 99 deletions

View File

@ -1762,8 +1762,7 @@ void Domain::add_region(int narg, char **arg)
if (lmp->suffix_enable) { if (lmp->suffix_enable) {
if (lmp->suffix) { if (lmp->suffix) {
std::string estyle = arg[1]; std::string estyle = std::string(arg[1]) + "/" + lmp->suffix;
estyle += std::string("/") + lmp->suffix;
if (region_map->find(estyle) != region_map->end()) { if (region_map->find(estyle) != region_map->end()) {
RegionCreator region_creator = (*region_map)[estyle]; RegionCreator region_creator = (*region_map)[estyle];
regions[nregion] = region_creator(lmp, narg, arg); regions[nregion] = region_creator(lmp, narg, arg);
@ -1774,8 +1773,7 @@ void Domain::add_region(int narg, char **arg)
} }
if (lmp->suffix2) { if (lmp->suffix2) {
std::string estyle = arg[1]; std::string estyle = std::string(arg[1]) + "/" + lmp->suffix2;
estyle += std::string("/") + lmp->suffix2;
if (region_map->find(estyle) != region_map->end()) { if (region_map->find(estyle) != region_map->end()) {
RegionCreator region_creator = (*region_map)[estyle]; RegionCreator region_creator = (*region_map)[estyle];
regions[nregion] = region_creator(lmp, narg, arg); regions[nregion] = region_creator(lmp, narg, arg);

View File

@ -234,7 +234,7 @@ void Force::setup()
create a pair style, called from input script or restart file create a pair style, called from input script or restart file
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void Force::create_pair(const char *style, int trysuffix) void Force::create_pair(const std::string &style, int trysuffix)
{ {
delete [] pair_style; delete [] pair_style;
if (pair) delete pair; if (pair) delete pair;
@ -254,13 +254,12 @@ void Force::create_pair(const char *style, int trysuffix)
return sflag = 0 for no suffix added, 1 or 2 for suffix1/2 added return sflag = 0 for no suffix added, 1 or 2 for suffix1/2 added
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
Pair *Force::new_pair(const char *style, int trysuffix, int &sflag) Pair *Force::new_pair(const std::string &style, int trysuffix, int &sflag)
{ {
if (trysuffix && lmp->suffix_enable) { if (trysuffix && lmp->suffix_enable) {
if (lmp->suffix) { if (lmp->suffix) {
sflag = 1; sflag = 1;
char estyle[256]; std::string estyle = style + "/" + lmp->suffix;
snprintf(estyle,256,"%s/%s",style,lmp->suffix);
if (pair_map->find(estyle) != pair_map->end()) { if (pair_map->find(estyle) != pair_map->end()) {
PairCreator pair_creator = (*pair_map)[estyle]; PairCreator pair_creator = (*pair_map)[estyle];
return pair_creator(lmp); return pair_creator(lmp);
@ -268,8 +267,7 @@ Pair *Force::new_pair(const char *style, int trysuffix, int &sflag)
} }
if (lmp->suffix2) { if (lmp->suffix2) {
sflag = 2; sflag = 2;
char estyle[256]; std::string estyle = style + "/" + lmp->suffix2;
snprintf(estyle,256,"%s/%s",style,lmp->suffix2);
if (pair_map->find(estyle) != pair_map->end()) { if (pair_map->find(estyle) != pair_map->end()) {
PairCreator pair_creator = (*pair_map)[estyle]; PairCreator pair_creator = (*pair_map)[estyle];
return pair_creator(lmp); return pair_creator(lmp);
@ -278,7 +276,7 @@ Pair *Force::new_pair(const char *style, int trysuffix, int &sflag)
} }
sflag = 0; sflag = 0;
if (strcmp(style,"none") == 0) return NULL; if (style == "none") return NULL;
if (pair_map->find(style) != pair_map->end()) { if (pair_map->find(style) != pair_map->end()) {
PairCreator pair_creator = (*pair_map)[style]; PairCreator pair_creator = (*pair_map)[style];
return pair_creator(lmp); return pair_creator(lmp);
@ -307,17 +305,17 @@ Pair *Force::pair_creator(LAMMPS *lmp)
return NULL if no match or if nsub=0 and multiple sub-styles match return NULL if no match or if nsub=0 and multiple sub-styles match
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
Pair *Force::pair_match(const char *word, int exact, int nsub) Pair *Force::pair_match(const std::string &word, int exact, int nsub)
{ {
int iwhich,count; int iwhich,count;
if (exact && strcmp(pair_style,word) == 0) return pair; if (exact && (word == pair_style)) return pair;
else if (!exact && utils::strmatch(pair_style,word)) return pair; else if (!exact && utils::strmatch(pair_style,word)) return pair;
else if (utils::strmatch(pair_style,"^hybrid")) { else if (utils::strmatch(pair_style,"^hybrid")) {
PairHybrid *hybrid = (PairHybrid *) pair; PairHybrid *hybrid = (PairHybrid *) pair;
count = 0; count = 0;
for (int i = 0; i < hybrid->nstyles; i++) for (int i = 0; i < hybrid->nstyles; i++)
if ((exact && strcmp(hybrid->keywords[i],word) == 0) || if ((exact && (word == hybrid->keywords[i])) ||
(!exact && utils::strmatch(hybrid->keywords[i],word))) { (!exact && utils::strmatch(hybrid->keywords[i],word))) {
iwhich = i; iwhich = i;
count++; count++;
@ -352,7 +350,7 @@ char *Force::pair_match_ptr(Pair *ptr)
create a bond style, called from input script or restart file create a bond style, called from input script or restart file
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void Force::create_bond(const char *style, int trysuffix) void Force::create_bond(const std::string &style, int trysuffix)
{ {
delete [] bond_style; delete [] bond_style;
if (bond) delete bond; if (bond) delete bond;
@ -366,13 +364,12 @@ void Force::create_bond(const char *style, int trysuffix)
generate a bond class, fist with suffix appended generate a bond class, fist with suffix appended
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
Bond *Force::new_bond(const char *style, int trysuffix, int &sflag) Bond *Force::new_bond(const std::string &style, int trysuffix, int &sflag)
{ {
if (trysuffix && lmp->suffix_enable) { if (trysuffix && lmp->suffix_enable) {
if (lmp->suffix) { if (lmp->suffix) {
sflag = 1; sflag = 1;
char estyle[256]; std::string estyle = style + "/" + lmp->suffix;
snprintf(estyle,256,"%s/%s",style,lmp->suffix);
if (bond_map->find(estyle) != bond_map->end()) { if (bond_map->find(estyle) != bond_map->end()) {
BondCreator bond_creator = (*bond_map)[estyle]; BondCreator bond_creator = (*bond_map)[estyle];
return bond_creator(lmp); return bond_creator(lmp);
@ -381,8 +378,7 @@ Bond *Force::new_bond(const char *style, int trysuffix, int &sflag)
if (lmp->suffix2) { if (lmp->suffix2) {
sflag = 2; sflag = 2;
char estyle[256]; std::string estyle = style + "/" + lmp->suffix2;
snprintf(estyle,256,"%s/%s",style,lmp->suffix2);
if (bond_map->find(estyle) != bond_map->end()) { if (bond_map->find(estyle) != bond_map->end()) {
BondCreator bond_creator = (*bond_map)[estyle]; BondCreator bond_creator = (*bond_map)[estyle];
return bond_creator(lmp); return bond_creator(lmp);
@ -391,7 +387,7 @@ Bond *Force::new_bond(const char *style, int trysuffix, int &sflag)
} }
sflag = 0; sflag = 0;
if (strcmp(style,"none") == 0) return NULL; if (style == "none") return NULL;
if (bond_map->find(style) != bond_map->end()) { if (bond_map->find(style) != bond_map->end()) {
BondCreator bond_creator = (*bond_map)[style]; BondCreator bond_creator = (*bond_map)[style];
return bond_creator(lmp); return bond_creator(lmp);
@ -416,13 +412,13 @@ Bond *Force::bond_creator(LAMMPS *lmp)
return ptr to current bond class or hybrid sub-class if matches style return ptr to current bond class or hybrid sub-class if matches style
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
Bond *Force::bond_match(const char *style) Bond *Force::bond_match(const std::string &style)
{ {
if (strcmp(bond_style,style) == 0) return bond; if (style == bond_style) return bond;
else if (strcmp(bond_style,"hybrid") == 0) { else if (strcmp(bond_style,"hybrid") == 0) {
BondHybrid *hybrid = (BondHybrid *) bond; BondHybrid *hybrid = (BondHybrid *) bond;
for (int i = 0; i < hybrid->nstyles; i++) for (int i = 0; i < hybrid->nstyles; i++)
if (strcmp(hybrid->keywords[i],style) == 0) return hybrid->styles[i]; if (style == hybrid->keywords[i]) return hybrid->styles[i];
} }
return NULL; return NULL;
} }
@ -431,7 +427,7 @@ Bond *Force::bond_match(const char *style)
create an angle style, called from input script or restart file create an angle style, called from input script or restart file
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void Force::create_angle(const char *style, int trysuffix) void Force::create_angle(const std::string &style, int trysuffix)
{ {
delete [] angle_style; delete [] angle_style;
if (angle) delete angle; if (angle) delete angle;
@ -445,13 +441,12 @@ void Force::create_angle(const char *style, int trysuffix)
generate an angle class generate an angle class
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
Angle *Force::new_angle(const char *style, int trysuffix, int &sflag) Angle *Force::new_angle(const std::string &style, int trysuffix, int &sflag)
{ {
if (trysuffix && lmp->suffix_enable) { if (trysuffix && lmp->suffix_enable) {
if (lmp->suffix) { if (lmp->suffix) {
sflag = 1; sflag = 1;
char estyle[256]; std::string estyle = style + "/" + lmp->suffix;
snprintf(estyle,256,"%s/%s",style,lmp->suffix);
if (angle_map->find(estyle) != angle_map->end()) { if (angle_map->find(estyle) != angle_map->end()) {
AngleCreator angle_creator = (*angle_map)[estyle]; AngleCreator angle_creator = (*angle_map)[estyle];
return angle_creator(lmp); return angle_creator(lmp);
@ -460,8 +455,7 @@ Angle *Force::new_angle(const char *style, int trysuffix, int &sflag)
if (lmp->suffix2) { if (lmp->suffix2) {
sflag = 2; sflag = 2;
char estyle[256]; std::string estyle = style + "/" + lmp->suffix;
snprintf(estyle,256,"%s/%s",style,lmp->suffix);
if (angle_map->find(estyle) != angle_map->end()) { if (angle_map->find(estyle) != angle_map->end()) {
AngleCreator angle_creator = (*angle_map)[estyle]; AngleCreator angle_creator = (*angle_map)[estyle];
return angle_creator(lmp); return angle_creator(lmp);
@ -470,7 +464,7 @@ Angle *Force::new_angle(const char *style, int trysuffix, int &sflag)
} }
sflag = 0; sflag = 0;
if (strcmp(style,"none") == 0) return NULL; if (style == "none") return NULL;
if (angle_map->find(style) != angle_map->end()) { if (angle_map->find(style) != angle_map->end()) {
AngleCreator angle_creator = (*angle_map)[style]; AngleCreator angle_creator = (*angle_map)[style];
return angle_creator(lmp); return angle_creator(lmp);
@ -491,18 +485,17 @@ Angle *Force::angle_creator(LAMMPS *lmp)
return new T(lmp); return new T(lmp);
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
return ptr to current angle class or hybrid sub-class if matches style return ptr to current angle class or hybrid sub-class if matches style
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
Angle *Force::angle_match(const char *style) Angle *Force::angle_match(const std::string &style)
{ {
if (strcmp(angle_style,style) == 0) return angle; if (style == angle_style) return angle;
else if (strcmp(angle_style,"hybrid") == 0) { else if (utils::strmatch(angle_style,"^hybrid")) {
AngleHybrid *hybrid = (AngleHybrid *) angle; AngleHybrid *hybrid = (AngleHybrid *) angle;
for (int i = 0; i < hybrid->nstyles; i++) for (int i = 0; i < hybrid->nstyles; i++)
if (strcmp(hybrid->keywords[i],style) == 0) return hybrid->styles[i]; if (style == hybrid->keywords[i]) return hybrid->styles[i];
} }
return NULL; return NULL;
} }
@ -511,7 +504,7 @@ Angle *Force::angle_match(const char *style)
create a dihedral style, called from input script or restart file create a dihedral style, called from input script or restart file
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void Force::create_dihedral(const char *style, int trysuffix) void Force::create_dihedral(const std::string &style, int trysuffix)
{ {
delete [] dihedral_style; delete [] dihedral_style;
if (dihedral) delete dihedral; if (dihedral) delete dihedral;
@ -525,13 +518,12 @@ void Force::create_dihedral(const char *style, int trysuffix)
generate a dihedral class generate a dihedral class
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
Dihedral *Force::new_dihedral(const char *style, int trysuffix, int &sflag) Dihedral *Force::new_dihedral(const std::string &style, int trysuffix, int &sflag)
{ {
if (trysuffix && lmp->suffix_enable) { if (trysuffix && lmp->suffix_enable) {
if (lmp->suffix) { if (lmp->suffix) {
sflag = 1; sflag = 1;
char estyle[256]; std::string estyle = style + "/" + lmp->suffix;
snprintf(estyle,256,"%s/%s",style,lmp->suffix);
if (dihedral_map->find(estyle) != dihedral_map->end()) { if (dihedral_map->find(estyle) != dihedral_map->end()) {
DihedralCreator dihedral_creator = (*dihedral_map)[estyle]; DihedralCreator dihedral_creator = (*dihedral_map)[estyle];
return dihedral_creator(lmp); return dihedral_creator(lmp);
@ -540,8 +532,7 @@ Dihedral *Force::new_dihedral(const char *style, int trysuffix, int &sflag)
if (lmp->suffix2) { if (lmp->suffix2) {
sflag = 2; sflag = 2;
char estyle[256]; std::string estyle = style + "/" + lmp->suffix2;
snprintf(estyle,256,"%s/%s",style,lmp->suffix2);
if (dihedral_map->find(estyle) != dihedral_map->end()) { if (dihedral_map->find(estyle) != dihedral_map->end()) {
DihedralCreator dihedral_creator = (*dihedral_map)[estyle]; DihedralCreator dihedral_creator = (*dihedral_map)[estyle];
return dihedral_creator(lmp); return dihedral_creator(lmp);
@ -550,7 +541,7 @@ Dihedral *Force::new_dihedral(const char *style, int trysuffix, int &sflag)
} }
sflag = 0; sflag = 0;
if (strcmp(style,"none") == 0) return NULL; if (style == "none") return NULL;
if (dihedral_map->find(style) != dihedral_map->end()) { if (dihedral_map->find(style) != dihedral_map->end()) {
DihedralCreator dihedral_creator = (*dihedral_map)[style]; DihedralCreator dihedral_creator = (*dihedral_map)[style];
return dihedral_creator(lmp); return dihedral_creator(lmp);
@ -575,13 +566,13 @@ Dihedral *Force::dihedral_creator(LAMMPS *lmp)
return ptr to current angle class or hybrid sub-class if matches style return ptr to current angle class or hybrid sub-class if matches style
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
Dihedral *Force::dihedral_match(const char *style) Dihedral *Force::dihedral_match(const std::string &style)
{ {
if (strcmp(dihedral_style,style) == 0) return dihedral; if (style == dihedral_style) return dihedral;
else if (strcmp(dihedral_style,"hybrid") == 0) { else if (utils::strmatch(dihedral_style,"^hybrid")) {
DihedralHybrid *hybrid = (DihedralHybrid *) dihedral; DihedralHybrid *hybrid = (DihedralHybrid *) dihedral;
for (int i = 0; i < hybrid->nstyles; i++) for (int i = 0; i < hybrid->nstyles; i++)
if (strcmp(hybrid->keywords[i],style) == 0) return hybrid->styles[i]; if (style == hybrid->keywords[i]) return hybrid->styles[i];
} }
return NULL; return NULL;
} }
@ -590,7 +581,7 @@ Dihedral *Force::dihedral_match(const char *style)
create an improper style, called from input script or restart file create an improper style, called from input script or restart file
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void Force::create_improper(const char *style, int trysuffix) void Force::create_improper(const std::string &style, int trysuffix)
{ {
delete [] improper_style; delete [] improper_style;
if (improper) delete improper; if (improper) delete improper;
@ -604,13 +595,12 @@ void Force::create_improper(const char *style, int trysuffix)
generate a improper class generate a improper class
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
Improper *Force::new_improper(const char *style, int trysuffix, int &sflag) Improper *Force::new_improper(const std::string &style, int trysuffix, int &sflag)
{ {
if (trysuffix && lmp->suffix_enable) { if (trysuffix && lmp->suffix_enable) {
if (lmp->suffix) { if (lmp->suffix) {
sflag = 1; sflag = 1;
char estyle[256]; std::string estyle = style + "/" + lmp->suffix;
snprintf(estyle,256,"%s/%s",style,lmp->suffix);
if (improper_map->find(estyle) != improper_map->end()) { if (improper_map->find(estyle) != improper_map->end()) {
ImproperCreator improper_creator = (*improper_map)[estyle]; ImproperCreator improper_creator = (*improper_map)[estyle];
return improper_creator(lmp); return improper_creator(lmp);
@ -619,8 +609,7 @@ Improper *Force::new_improper(const char *style, int trysuffix, int &sflag)
if (lmp->suffix2) { if (lmp->suffix2) {
sflag = 2; sflag = 2;
char estyle[256]; std::string estyle = style + "/" + lmp->suffix2;
snprintf(estyle,256,"%s/%s",style,lmp->suffix2);
if (improper_map->find(estyle) != improper_map->end()) { if (improper_map->find(estyle) != improper_map->end()) {
ImproperCreator improper_creator = (*improper_map)[estyle]; ImproperCreator improper_creator = (*improper_map)[estyle];
return improper_creator(lmp); return improper_creator(lmp);
@ -629,7 +618,7 @@ Improper *Force::new_improper(const char *style, int trysuffix, int &sflag)
} }
sflag = 0; sflag = 0;
if (strcmp(style,"none") == 0) return NULL; if (style == "none") return NULL;
if (improper_map->find(style) != improper_map->end()) { if (improper_map->find(style) != improper_map->end()) {
ImproperCreator improper_creator = (*improper_map)[style]; ImproperCreator improper_creator = (*improper_map)[style];
return improper_creator(lmp); return improper_creator(lmp);
@ -654,13 +643,13 @@ Improper *Force::improper_creator(LAMMPS *lmp)
return ptr to current improper class or hybrid sub-class if matches style return ptr to current improper class or hybrid sub-class if matches style
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
Improper *Force::improper_match(const char *style) Improper *Force::improper_match(const std::string &style)
{ {
if (strcmp(improper_style,style) == 0) return improper; if (style == improper_style) return improper;
else if (strcmp(improper_style,"hybrid") == 0) { else if (utils::strmatch(improper_style,"^hybrid")) {
ImproperHybrid *hybrid = (ImproperHybrid *) improper; ImproperHybrid *hybrid = (ImproperHybrid *) improper;
for (int i = 0; i < hybrid->nstyles; i++) for (int i = 0; i < hybrid->nstyles; i++)
if (strcmp(hybrid->keywords[i],style) == 0) return hybrid->styles[i]; if (style == hybrid->keywords[i]) return hybrid->styles[i];
} }
return NULL; return NULL;
} }
@ -669,7 +658,7 @@ Improper *Force::improper_match(const char *style)
new kspace style new kspace style
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void Force::create_kspace(const char *style, int trysuffix) void Force::create_kspace(const std::string &style, int trysuffix)
{ {
delete [] kspace_style; delete [] kspace_style;
if (kspace) delete kspace; if (kspace) delete kspace;
@ -687,13 +676,12 @@ void Force::create_kspace(const char *style, int trysuffix)
generate a kspace class generate a kspace class
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
KSpace *Force::new_kspace(const char *style, int trysuffix, int &sflag) KSpace *Force::new_kspace(const std::string &style, int trysuffix, int &sflag)
{ {
if (trysuffix && lmp->suffix_enable) { if (trysuffix && lmp->suffix_enable) {
if (lmp->suffix) { if (lmp->suffix) {
sflag = 1; sflag = 1;
char estyle[256]; std::string estyle = style + "/" + lmp->suffix;
snprintf(estyle,256,"%s/%s",style,lmp->suffix);
if (kspace_map->find(estyle) != kspace_map->end()) { if (kspace_map->find(estyle) != kspace_map->end()) {
KSpaceCreator kspace_creator = (*kspace_map)[estyle]; KSpaceCreator kspace_creator = (*kspace_map)[estyle];
return kspace_creator(lmp); return kspace_creator(lmp);
@ -702,8 +690,7 @@ KSpace *Force::new_kspace(const char *style, int trysuffix, int &sflag)
if (lmp->suffix2) { if (lmp->suffix2) {
sflag = 1; sflag = 1;
char estyle[256]; std::string estyle = style + "/" + lmp->suffix2;
snprintf(estyle,256,"%s/%s",style,lmp->suffix2);
if (kspace_map->find(estyle) != kspace_map->end()) { if (kspace_map->find(estyle) != kspace_map->end()) {
KSpaceCreator kspace_creator = (*kspace_map)[estyle]; KSpaceCreator kspace_creator = (*kspace_map)[estyle];
return kspace_creator(lmp); return kspace_creator(lmp);
@ -712,7 +699,7 @@ KSpace *Force::new_kspace(const char *style, int trysuffix, int &sflag)
} }
sflag = 0; sflag = 0;
if (strcmp(style,"none") == 0) return NULL; if (style == "none") return NULL;
if (kspace_map->find(style) != kspace_map->end()) { if (kspace_map->find(style) != kspace_map->end()) {
KSpaceCreator kspace_creator = (*kspace_map)[style]; KSpaceCreator kspace_creator = (*kspace_map)[style];
return kspace_creator(lmp); return kspace_creator(lmp);
@ -740,9 +727,9 @@ KSpace *Force::kspace_creator(LAMMPS *lmp)
return NULL if no match return NULL if no match
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
KSpace *Force::kspace_match(const char *word, int exact) KSpace *Force::kspace_match(const std::string &word, int exact)
{ {
if (exact && strcmp(kspace_style,word) == 0) return kspace; if (exact && (word == kspace_style)) return kspace;
else if (!exact && utils::strmatch(kspace_style,word)) return kspace; else if (!exact && utils::strmatch(kspace_style,word)) return kspace;
return NULL; return NULL;
} }
@ -753,20 +740,15 @@ KSpace *Force::kspace_match(const char *word, int exact)
if sflag = 1/2, append suffix or suffix2 to style if sflag = 1/2, append suffix or suffix2 to style
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void Force::store_style(char *&str, const char *style, int sflag) void Force::store_style(char *&str, const std::string &style, int sflag)
{ {
if (sflag) { std::string estyle = style;
char estyle[256];
if (sflag == 1) snprintf(estyle,256,"%s/%s",style,lmp->suffix); if (sflag == 1) estyle += std::string("/") + lmp->suffix;
else snprintf(estyle,256,"%s/%s",style,lmp->suffix2); else if (sflag == 2) estyle += std::string("/") + lmp->suffix2;
int n = strlen(estyle) + 1;
str = new char[n]; str = new char[estyle.size()+1];
strcpy(str,estyle); strcpy(str,estyle.c_str());
} else {
int n = strlen(style) + 1;
str = new char[n];
strcpy(str,style);
}
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------

View File

@ -101,32 +101,32 @@ class Force : protected Pointers {
void init(); void init();
void setup(); void setup();
void create_pair(const char *, int); void create_pair(const std::string &, int);
class Pair *new_pair(const char *, int, int &); class Pair *new_pair(const std::string &, int, int &);
class Pair *pair_match(const char *, int, int nsub=0); class Pair *pair_match(const std::string &, int, int nsub=0);
char *pair_match_ptr(Pair *); char *pair_match_ptr(Pair *);
void create_bond(const char *, int); void create_bond(const std::string &, int);
class Bond *new_bond(const char *, int, int &); class Bond *new_bond(const std::string &, int, int &);
class Bond *bond_match(const char *); class Bond *bond_match(const std::string &);
void create_angle(const char *, int); void create_angle(const std::string &, int);
class Angle *new_angle(const char *, int, int &); class Angle *new_angle(const std::string &, int, int &);
class Angle *angle_match(const char *); class Angle *angle_match(const std::string &);
void create_dihedral(const char *, int); void create_dihedral(const std::string &, int);
class Dihedral *new_dihedral(const char *, int, int &); class Dihedral *new_dihedral(const std::string &, int, int &);
class Dihedral *dihedral_match(const char *); class Dihedral *dihedral_match(const std::string &);
void create_improper(const char *, int); void create_improper(const std::string &, int);
class Improper *new_improper(const char *, int, int &); class Improper *new_improper(const std::string &, int, int &);
class Improper *improper_match(const char *); class Improper *improper_match(const std::string &);
void create_kspace(const char *, int); void create_kspace(const std::string &, int);
class KSpace *new_kspace(const char *, int, int &); class KSpace *new_kspace(const std::string &, int, int &);
class KSpace *kspace_match(const char *, int); class KSpace *kspace_match(const std::string &, int);
void store_style(char *&, const char *, int); void store_style(char *&, const std::string &, int);
void set_special(int, char **); void set_special(int, char **);
void bounds(const char *, int, char *, int, int &, int &, int nmin=1); void bounds(const char *, int, char *, int, int &, int &, int nmin=1);
void boundsbig(const char *, int, char *, bigint, bigint &, bigint &, bigint nmin=1); void boundsbig(const char *, int, char *, bigint, bigint &, bigint &, bigint nmin=1);