From e770f8ade6b0580f97319695f22746dcf47db7d7 Mon Sep 17 00:00:00 2001 From: Luc Grosheintz Date: Thu, 10 Aug 2023 13:57:59 +0200 Subject: [PATCH 1/3] Fix leak in `write_nrnthread`. --- src/nrniv/nrncore_write/io/nrncore_io.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nrniv/nrncore_write/io/nrncore_io.cpp b/src/nrniv/nrncore_write/io/nrncore_io.cpp index 8c5a80b0cf..000da40322 100644 --- a/src/nrniv/nrncore_write/io/nrncore_io.cpp +++ b/src/nrniv/nrncore_write/io/nrncore_io.cpp @@ -215,7 +215,7 @@ void write_nrnthread(const char* path, NrnThread& nt, CellGroup& cg) { writeint(nodeindices, n); } writedbl(data, n * sz); - if (nrn_is_artificial_[type]) { + if (data) { delete[] data; } sz = bbcore_dparam_size[type]; From 0e7d4a277a5a51de1e24fcddfdee59e44aa3d402 Mon Sep 17 00:00:00 2001 From: Luc Grosheintz Date: Fri, 18 Aug 2023 20:44:11 +0200 Subject: [PATCH 2/3] Remove commented out code. --- .../callbacks/nrncore_callbacks.cpp | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/nrniv/nrncore_write/callbacks/nrncore_callbacks.cpp b/src/nrniv/nrncore_write/callbacks/nrncore_callbacks.cpp index 1da8d53aea..0419b282db 100644 --- a/src/nrniv/nrncore_write/callbacks/nrncore_callbacks.cpp +++ b/src/nrniv/nrncore_write/callbacks/nrncore_callbacks.cpp @@ -352,8 +352,8 @@ int nrnthread_dat2_mech(int tid, int sz = nrn_prop_param_size_[type]; // As the NEURON data is now transposed then for now always create a new - // copy in the format expected by CoreNEURON -- TODO make sure this is - // freed, then later TODO remove the need for this entirely + // copy in the format expected by CoreNEURON. + // TODO remove the need for this entirely if (!copy) { data = new double[n * sz]; } @@ -363,13 +363,10 @@ int nrnthread_dat2_mech(int tid, } } - // double* data1; if (isart) { // data may not be contiguous - // data1 = contiguous_art_data(ml, n, sz); // delete after use nodeindices = NULL; } else { nodeindices = ml->nodeindices; // allocated below if copy - // data1 = ml->_data[0]; // do not delete after use } if (copy) { if (!isart) { @@ -378,15 +375,6 @@ int nrnthread_dat2_mech(int tid, nodeindices[i] = ml->nodeindices[i]; } } - // int nn = n * sz; - // for (int i = 0; i < nn; ++i) { - // data[i] = data1[i]; - // } - // if (isart) { - // delete[] data1; - // } - // } else { - // data = data1; } sz = bbcore_dparam_size[type]; // nrn_prop_dparam_size off by 1 if cvode_ieq. From 932cd3258fed91f347c314edb48251c2e37c277f Mon Sep 17 00:00:00 2001 From: Olli Lupton Date: Mon, 21 Aug 2023 12:10:42 +0200 Subject: [PATCH 3/3] remove unused methods --- src/nrniv/nrncore_write/io/nrncore_io.cpp | 22 ---------------------- src/nrniv/nrncore_write/io/nrncore_io.h | 2 -- 2 files changed, 24 deletions(-) diff --git a/src/nrniv/nrncore_write/io/nrncore_io.cpp b/src/nrniv/nrncore_write/io/nrncore_io.cpp index 000da40322..ef41bc3f48 100644 --- a/src/nrniv/nrncore_write/io/nrncore_io.cpp +++ b/src/nrniv/nrncore_write/io/nrncore_io.cpp @@ -304,28 +304,6 @@ void writedbl_(double* p, size_t size, FILE* f) { #define writeint(p, size) writeint_(p, size, f) #define writedbl(p, size) writedbl_(p, size, f) -void write_contiguous_art_data(double** data, int nitem, int szitem, FILE* f) { - fprintf(f, "chkpnt %d\n", chkpnt++); - // the assumption is that an fwrite of nitem groups of szitem doubles can be - // fread as a single group of nitem*szitem doubles. - for (int i = 0; i < nitem; ++i) { - size_t n = fwrite(data[i], sizeof(double), szitem, f); - assert(n == szitem); - } -} - -double* contiguous_art_data(Memb_list* ml, int nitem, int szitem) { - double* d1 = new double[nitem * szitem]; - int k = 0; - for (int i = 0; i < nitem; ++i) { - for (int j = 0; j < szitem; ++j) { - d1[k++] = ml->data(i, j); - } - } - return d1; -} - - void nrnbbcore_vecplay_write(FILE* f, NrnThread& nt) { // Get the indices in NetCvode.fixed_play_ for this thread // error if not a VecPlayContinuous with no discon vector diff --git a/src/nrniv/nrncore_write/io/nrncore_io.h b/src/nrniv/nrncore_write/io/nrncore_io.h index e0e6b1c98d..ee690b694d 100644 --- a/src/nrniv/nrncore_write/io/nrncore_io.h +++ b/src/nrniv/nrncore_write/io/nrncore_io.h @@ -38,8 +38,6 @@ struct Memb_list; using bbcore_write_t = void (*)(double*, int*, int*, int*, Memb_list*, std::size_t, Datum*, Datum*, NrnThread*); -void write_contiguous_art_data(double** data, int nitem, int szitem, FILE* f); -double* contiguous_art_data(Memb_list* ml, int nitem, int szitem); void write_nrnthread_task(const char*, CellGroup* cgs, bool append); void nrnbbcore_vecplay_write(FILE* f, NrnThread& nt);