use memory class for memory allocation consistently
This commit is contained in:
@ -20,6 +20,7 @@
|
||||
|
||||
#include "error.h"
|
||||
#include "input.h"
|
||||
#include "memory.h"
|
||||
#include "modify.h"
|
||||
|
||||
#include <cstdlib>
|
||||
@ -67,12 +68,12 @@ MDIPlugin::MDIPlugin(LAMMPS *_lmp, int narg, char **arg) : Pointers(_lmp)
|
||||
// do variable substitution in multiple word extra_arg
|
||||
|
||||
int ncopy = strlen(extra_arg) + 1;
|
||||
char *copy = (char *) malloc(ncopy);
|
||||
char *copy = (char *) memory->smalloc(ncopy,"mdi_plugin:copy");
|
||||
strncpy(copy, extra_arg, ncopy);
|
||||
char *work = (char *) malloc(ncopy);
|
||||
char *work = (char *) memory->smalloc(ncopy,"mdi_plugin:work");
|
||||
int nwork = ncopy;
|
||||
input->substitute(copy, work, ncopy, nwork, 0);
|
||||
free(work);
|
||||
memory->sfree(work);
|
||||
extra_arg = copy;
|
||||
|
||||
iarg += 2;
|
||||
@ -83,12 +84,12 @@ MDIPlugin::MDIPlugin(LAMMPS *_lmp, int narg, char **arg) : Pointers(_lmp)
|
||||
// do variable substitution in multiple word lammps_command
|
||||
|
||||
int ncopy = strlen(lammps_command) + 1;
|
||||
char *copy = (char *) malloc(ncopy);
|
||||
strncpy(copy, extra_arg, ncopy);
|
||||
char *work = (char *) malloc(ncopy);
|
||||
char *copy = (char *) memory->smalloc(ncopy,"mdi_plugin:work");
|
||||
strncpy(copy, lammps_command, ncopy);
|
||||
char *work = (char *) memory->smalloc(ncopy,"mdi_plugin:work");
|
||||
int nwork = ncopy;
|
||||
input->substitute(copy, work, ncopy, nwork, 0);
|
||||
free(work);
|
||||
memory->sfree(work);
|
||||
lammps_command = copy;
|
||||
|
||||
iarg += 2;
|
||||
@ -128,8 +129,8 @@ MDIPlugin::MDIPlugin(LAMMPS *_lmp, int narg, char **arg) : Pointers(_lmp)
|
||||
MDI_Launch_plugin(plugin_name, plugin_args, &world, plugin_wrapper, (void *) this);
|
||||
|
||||
delete[] plugin_args;
|
||||
delete[] extra_arg;
|
||||
delete[] lammps_command;
|
||||
memory->sfree(extra_arg);
|
||||
memory->sfree(lammps_command);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user