ensure liftime of temporary storage

This commit is contained in:
Axel Kohlmeyer
2022-08-05 04:23:55 -04:00
parent 7ebd65ddb7
commit f448fd4191

View File

@ -49,8 +49,7 @@ void WriteDump::command(int narg, char **arg)
dumpargs[0] = (char *) "WRITE_DUMP"; // dump id
dumpargs[1] = arg[0]; // group
dumpargs[2] = arg[1]; // dump style
std::string ntimestep = std::to_string(MAX(update->ntimestep, 1));
dumpargs[3] = (char *) ntimestep.c_str(); // dump frequency
dumpargs[3] = utils::strdup(std::to_string(MAX(update->ntimestep, 1))); // dump frequency
for (int i = 2; i < modindex; ++i) dumpargs[i + 2] = arg[i];
@ -61,9 +60,7 @@ void WriteDump::command(int narg, char **arg)
// set multifile_override for DumpImage so that filename needs no "*"
if (strcmp(arg[1], "image") == 0) (dynamic_cast<DumpImage *>(dump))->multifile_override = 1;
if (strcmp(arg[1], "cfg") == 0) (dynamic_cast<DumpCFG *>(dump))->multifile_override = 1;
if ((update->first_update == 0) && (comm->me == 0))
error->warning(FLERR, "Calling write_dump before a full system init.");
@ -73,5 +70,6 @@ void WriteDump::command(int narg, char **arg)
// delete the Dump instance and local storage
output->delete_dump(dumpargs[0]);
delete[] dumpargs[3];
delete[] dumpargs;
}