Is it possible to use mxCalloc and mxFree in S-Functions?

I created identical S-Functions with dynamic memory allocation. One uses calloc/free and it works fine. The other one uses mxCalloc/mxFree and it crashes every now and then when simulating.

 Accepted Answer

Standard MATLAB API memory allocation routines mxCalloc and mxFree are designed to be used with MEX-files that are called from MATLAB, not from Simulink. In S-Functions, use the stdlib.h library routines calloc and free.
 

More Answers (0)

Products

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!