Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix leak in write_nrnthread. #2456

Merged
merged 3 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions src/nrniv/nrncore_write/callbacks/nrncore_callbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand All @@ -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) {
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/nrniv/nrncore_write/io/nrncore_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
olupton marked this conversation as resolved.
Show resolved Hide resolved
}
sz = bbcore_dparam_size[type];
Expand Down
Loading