mcdougallab / matlabneuroninterface

Interface for connecting NEURON and MATLAB
BSD 3-Clause "New" or "Revised" License
5 stars 1 forks source link

Allow for multiple strings on the NEURON stack #25

Open edovanveen opened 1 year ago

edovanveen commented 1 year ago

See source/nrnmatlab.cpp, function matlab_hoc_pushstr

By using a static char* here, we can only ever have one string on the stack, which is enough for our current example scripts. However, adding a second string changes the first one. Maybe this can be fixed in the future by using something like:

         char** ts = hoc_temp_charptr();
         *ts = strin.c_str();
         hoc_pushstr(ts);

In that case we need to keep track of ts and free it later to prevent a memory leak. Moreover, hoc_temp_charptr can only hold 128 items.