Index: mttroot/mtt/lib/rep/sfun_rep/sfun.cc.tmpl ================================================================== --- mttroot/mtt/lib/rep/sfun_rep/sfun.cc.tmpl +++ mttroot/mtt/lib/rep/sfun_rep/sfun.cc.tmpl @@ -104,10 +104,12 @@ mexCallMATLAB (1, plhs, 1, prhs, "_state"); for (int i = 0; i < MTTNX; i++) { ssGetContStates (S)[i] = states [i]; } + + mxDestroyArray (plhs[0]); } static void mdlOutputs(SimStruct *S, int_T tid) { static mxArray *plhs[1]; @@ -129,10 +131,12 @@ double *outputs = mxGetPr (plhs[0]); for (int i = 0; i < MTTNY; i++) { ssGetOutputPortRealSignal (S,i)[0] = outputs [i]; } + + mxDestroyArray (plhs[0]); } #define MDL_DERIVATIVES static void mdlDerivatives(SimStruct *S) { @@ -153,10 +157,12 @@ double *rates= mxGetPr (plhs[0]); for (int i = 0; i < MTTNX; i++) { ssGetdX (S)[i] = rates [i]; } + + mxDestroyArray (plhs[0]); } static void mdlTerminate(SimStruct *S) { UNUSED_ARG(S);