From 47edf5effa5c6a1e64e39778f6c8feec3a9fa30c Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 3 Dec 2023 04:33:00 -0500 Subject: [PATCH] use memory class for memory allocation consistently --- src/MDI/mdi_plugin.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/MDI/mdi_plugin.cpp b/src/MDI/mdi_plugin.cpp index d7805d0cba..92b78b6afb 100644 --- a/src/MDI/mdi_plugin.cpp +++ b/src/MDI/mdi_plugin.cpp @@ -20,6 +20,7 @@ #include "error.h" #include "input.h" +#include "memory.h" #include "modify.h" #include @@ -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); } /* ----------------------------------------------------------------------