apply utils::strdup() in a few more cases

This commit is contained in:
Axel Kohlmeyer
2021-02-04 17:52:32 -05:00
parent 5c8bbb42f6
commit cf427bcad8
14 changed files with 83 additions and 159 deletions

View File

@ -12,20 +12,20 @@
------------------------------------------------------------------------- */
#include "fix_temp_berendsen.h"
#include <cstring>
#include <cmath>
#include "atom.h"
#include "force.h"
#include "comm.h"
#include "input.h"
#include "variable.h"
#include "group.h"
#include "update.h"
#include "modify.h"
#include "compute.h"
#include "error.h"
#include "force.h"
#include "group.h"
#include "input.h"
#include "modify.h"
#include "update.h"
#include "variable.h"
#include <cmath>
#include <cstring>
using namespace LAMMPS_NS;
using namespace FixConst;
@ -52,9 +52,7 @@ FixTempBerendsen::FixTempBerendsen(LAMMPS *lmp, int narg, char **arg) :
tstr = nullptr;
if (utils::strmatch(arg[3],"^v_")) {
int n = strlen(&arg[3][2]) + 1;
tstr = new char[n];
strcpy(tstr,&arg[3][2]);
tstr = utils::strdup(arg[3]+2);
tstyle = EQUAL;
} else {
t_start = utils::numeric(FLERR,arg[3],false,lmp);
@ -74,9 +72,7 @@ FixTempBerendsen::FixTempBerendsen(LAMMPS *lmp, int narg, char **arg) :
// id = fix-ID + temp, compute group = fix group
std::string cmd = id + std::string("_temp");
id_temp = new char[cmd.size()+1];
strcpy(id_temp,cmd.c_str());
id_temp = utils::strdup(cmd);
cmd += fmt::format(" {} temp",group->names[igroup]);
modify->add_compute(cmd);
tflag = 1;