From aa2d2509d8b58eb9dd372b15b59d8188d2f0d969 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 13 Jan 2023 05:40:28 -0500 Subject: [PATCH] plug memory leaks in coupling examples --- examples/COUPLE/plugin/simple.c | 1 + examples/COUPLE/simple/simple.c | 1 + examples/COUPLE/simple/simple.cpp | 6 +++--- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/COUPLE/plugin/simple.c b/examples/COUPLE/plugin/simple.c index 535086f7ad..9151f92848 100644 --- a/examples/COUPLE/plugin/simple.c +++ b/examples/COUPLE/plugin/simple.c @@ -148,6 +148,7 @@ int main(int narg, char **arg) double *fx = (double *) plugin->extract_variable(lmp,"fx",(char *)"all"); printf("Force on 1 atom via extract_variable: %g\n",fx[0]); + plugin->free(fx); } /* use commands_string() and commands_list() to invoke more commands */ diff --git a/examples/COUPLE/simple/simple.c b/examples/COUPLE/simple/simple.c index 6018ee9465..aba3ef8d2d 100644 --- a/examples/COUPLE/simple/simple.c +++ b/examples/COUPLE/simple/simple.c @@ -121,6 +121,7 @@ int main(int narg, char **arg) double *fx = (double *) lammps_extract_variable(lmp,"fx","all"); printf("Force on 1 atom via extract_variable: %g\n",fx[0]); + lammps_free(fx); } /* use commands_string() and commands_list() to invoke more commands */ diff --git a/examples/COUPLE/simple/simple.cpp b/examples/COUPLE/simple/simple.cpp index fe7ca31b4b..c8727cc81f 100644 --- a/examples/COUPLE/simple/simple.cpp +++ b/examples/COUPLE/simple/simple.cpp @@ -125,12 +125,12 @@ int main(int narg, char **arg) // extract force on single atom two different ways if (lammps == 1) { - double **f = (double **) lammps_extract_atom(lmp,(char *) "f"); + double **f = (double **) lammps_extract_atom(lmp, "f"); printf("Force on 1 atom via extract_atom: %g\n",f[0][0]); - double *fx = (double *) - lammps_extract_variable(lmp,(char *) "fx",(char *) "all"); + double *fx = (double *) lammps_extract_variable(lmp, "fx", "all"); printf("Force on 1 atom via extract_variable: %g\n",fx[0]); + lammps_free(fx); } // use commands_string() and commands_list() to invoke more commands