Correctly build argv with nullptr at the end
This commit is contained in:
committed by
Richard Berger
parent
e655cda066
commit
46768d0ff3
@ -107,6 +107,15 @@ using namespace LAMMPS_NS;
|
||||
* The specifics of setting up and running a simulation are handled by the
|
||||
* individual component class instances. */
|
||||
|
||||
/** Create a LAMMPS simulation instance
|
||||
*
|
||||
* \param args list of arguments
|
||||
* \param communicator MPI communicator used by this LAMMPS instance
|
||||
*/
|
||||
LAMMPS::LAMMPS(argv & args, MPI_Comm communicator) :
|
||||
LAMMPS(args.size(), argv_pointers(args).data(), communicator) {
|
||||
}
|
||||
|
||||
/** Create a LAMMPS simulation instance
|
||||
*
|
||||
* The LAMMPS constructor starts up a simulation by allocating all
|
||||
@ -1464,3 +1473,17 @@ void LAMMPS::print_config(FILE *fp)
|
||||
}
|
||||
fputs("\n\n",fp);
|
||||
}
|
||||
|
||||
/** Create vector of argv string pointers including terminating nullptr element
|
||||
*
|
||||
* \param args list of arguments
|
||||
*/
|
||||
std::vector<char*> LAMMPS::argv_pointers(argv & args){
|
||||
std::vector<char*> r;
|
||||
r.reserve(args.size()+1);
|
||||
for(auto & a : args) {
|
||||
r.push_back((char*)a.data());
|
||||
}
|
||||
r.push_back(nullptr);
|
||||
return r;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user