Correctly build argv with nullptr at the end
This commit is contained in:
committed by
Richard Berger
parent
e655cda066
commit
46768d0ff3
@ -106,31 +106,21 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
std::string testbinary = "LAMMPSTest";
|
||||
std::vector<std::string> args = {"-log", "none", "-echo", "screen", "-nocite"};
|
||||
std::string testbinary = "LAMMPSTest";
|
||||
LAMMPS::argv args = {"-log", "none", "-echo", "screen", "-nocite"};
|
||||
LAMMPS *lmp;
|
||||
Info *info;
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
int argc = args.size() + 1;
|
||||
char **argv = new char *[argc];
|
||||
argv[0] = LAMMPS_NS::utils::strdup(testbinary);
|
||||
for (int i = 1; i < argc; i++) {
|
||||
argv[i] = LAMMPS_NS::utils::strdup(args[i - 1]);
|
||||
}
|
||||
LAMMPS::argv full_args = {testbinary};
|
||||
full_args.insert(full_args.end(), args.begin(), args.end());
|
||||
|
||||
HIDE_OUTPUT([&] {
|
||||
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
|
||||
lmp = new LAMMPS(full_args, MPI_COMM_WORLD);
|
||||
info = new Info(lmp);
|
||||
});
|
||||
InitSystem();
|
||||
|
||||
for (int i = 0; i < argc; i++) {
|
||||
delete[] argv[i];
|
||||
argv[i] = nullptr;
|
||||
}
|
||||
delete[] argv;
|
||||
}
|
||||
|
||||
virtual void InitSystem() {}
|
||||
|
||||
Reference in New Issue
Block a user