modernize and fix some memory leaks
This commit is contained in:
@ -18,9 +18,6 @@
|
||||
|
||||
#include "fix_mscg.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "mscg.h"
|
||||
#include "atom.h"
|
||||
#include "comm.h"
|
||||
#include "domain.h"
|
||||
@ -35,6 +32,10 @@
|
||||
#include "update.h"
|
||||
#include "variable.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "mscg.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace FixConst;
|
||||
|
||||
@ -49,8 +50,7 @@ FixMSCG::FixMSCG(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
me = comm->me;
|
||||
nprocs = comm->nprocs;
|
||||
if (nprocs > 1) error->all(FLERR,"Fix mscg does not yet support "
|
||||
"parallel use via MPI");
|
||||
if (nprocs > 1) error->all(FLERR,"Fix mscg does not yet support parallel use via MPI");
|
||||
|
||||
if (sizeof(tagint) != sizeof(smallint))
|
||||
error->all(FLERR,"Fix mscg must be used with 32-bit atom IDs");
|
||||
@ -89,23 +89,23 @@ FixMSCG::FixMSCG(LAMMPS *lmp, int narg, char **arg) :
|
||||
name_flag = 1;
|
||||
for (int i = 0; i < ntypes; i++) {
|
||||
iarg += 1;
|
||||
std::string str = arg[iarg];
|
||||
type_names[i] = strcat(strdup(str.c_str()),"\0");
|
||||
delete[] type_names[i];
|
||||
type_names[i] = utils::strdup(arg[iarg]);
|
||||
}
|
||||
iarg += 1;
|
||||
} else if (strcmp(arg[iarg],"max") == 0) {
|
||||
if (iarg+4 > narg) error->all(FLERR,"Illegal fix mscg command");
|
||||
max_partners_bond = atoi(arg[iarg+1]);
|
||||
max_partners_angle = atoi(arg[iarg+2]);
|
||||
max_partners_dihedral = atoi(arg[iarg+3]);
|
||||
max_partners_bond = utils::inumeric(FLERR,arg[iarg+1],false, lmp);
|
||||
max_partners_angle = utils::inumeric(FLERR,arg[iarg+2],false, lmp);
|
||||
max_partners_dihedral = utils::inumeric(FLERR,arg[iarg+3],false, lmp);
|
||||
iarg += 4;
|
||||
} else error->all(FLERR,"Illegal fix mscg command");
|
||||
}
|
||||
|
||||
if (name_flag == 0) {
|
||||
for (int i = 0; i < natoms; i++) {
|
||||
std::string str = std::to_string(i+1);
|
||||
type_names[i] = strcat(strdup(str.c_str()),"\0");
|
||||
delete[] type_names[i];
|
||||
type_names[i] = utils::strdup(std::to_string(i+1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -114,6 +114,9 @@ FixMSCG::FixMSCG(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
FixMSCG::~FixMSCG()
|
||||
{
|
||||
int natoms = atom->natoms;
|
||||
for (int i = 0; i < natoms; i++) delete[] type_names[i];
|
||||
delete[] type_names;
|
||||
memory->destroy(f);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user