From 3e2f3a80583494420eda14e4ce178f5b71695e60 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 10 Jun 2019 18:22:04 -0400 Subject: [PATCH] avoid a case of mixing malloc()/free() with new/delete --- src/variable.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/variable.cpp b/src/variable.cpp index 376cc8045a..7cbdc57d3a 100644 --- a/src/variable.cpp +++ b/src/variable.cpp @@ -288,11 +288,11 @@ void Variable::set(int narg, char **arg) int maxcopy = strlen(arg[2]) + 1; int maxwork = maxcopy; - char *scopy = new char[maxcopy]; - char *work = new char[maxwork]; + char *scopy = (char *) memory->smalloc(maxcopy,"var:string/copy"); + char *work = (char *) memory->smalloc(maxwork,"var:string/work"); strcpy(scopy,arg[2]); input->substitute(scopy,work,maxcopy,maxwork,1); - delete [] work; + memory->sfree(work); int ivar = find(arg[0]); if (ivar >= 0) { @@ -310,7 +310,7 @@ void Variable::set(int narg, char **arg) data[nvar] = new char*[num[nvar]]; copy(1,&scopy,data[nvar]); } - delete [] scopy; + memory->sfree(scopy); // GETENV // remove pre-existing var if also style GETENV (allows it to be reset)