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

3 views (last 30 days)
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

MathWorks Support Team
MathWorks Support Team on 4 Apr 2018
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)

Tags

Products

Community Treasure Hunt

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

Start Hunting!