replace variable length array on stack with std::unique_ptr()
this closes #2757
This commit is contained in:
@ -42,6 +42,7 @@
|
||||
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace FixConst;
|
||||
@ -724,7 +725,9 @@ void FixChargeRegulation::forward_ions_multival() {
|
||||
double energy_before = energy_stored;
|
||||
double factor = 1;
|
||||
double dummyp[3];
|
||||
int mm[salt_charge_ratio + 1];// particle ID array for all ions to be inserted
|
||||
|
||||
// particle ID array for all ions to be inserted
|
||||
auto mm = std::unique_ptr<int[]>(new int[salt_charge_ratio + 1]);
|
||||
|
||||
if (salt_charge[0] <= -salt_charge[1]) {
|
||||
// insert one anion and (salt_charge_ratio) cations
|
||||
@ -778,9 +781,12 @@ void FixChargeRegulation::backward_ions_multival() {
|
||||
double energy_before = energy_stored;
|
||||
double factor = 1;
|
||||
double dummyp[3]; // dummy particle
|
||||
int mm[salt_charge_ratio + 1]; // particle ID array for all deleted ions
|
||||
double qq[salt_charge_ratio + 1]; // charge array for all deleted ions
|
||||
int mask_tmp[salt_charge_ratio + 1]; // temporary mask array
|
||||
// particle ID array for all deleted ions
|
||||
auto mm = std::unique_ptr<int[]>(new int[salt_charge_ratio + 1]);
|
||||
// charge array for all deleted ions
|
||||
auto qq = std::unique_ptr<double[]>(new double[salt_charge_ratio + 1]);
|
||||
// temporary mask array
|
||||
auto mask_tmp = std::unique_ptr<int[]>(new int[salt_charge_ratio + 1]);
|
||||
|
||||
if (salt_charge[0] <= -salt_charge[1]) {
|
||||
// delete one anion and (salt_charge_ratio) cations
|
||||
|
||||
Reference in New Issue
Block a user