Is it possible to use mxCalloc and mxFree in S-Functions?
3 views (last 30 days)
Show older comments
MathWorks Support Team
on 31 Jul 2009
Edited: MathWorks Support Team
on 8 Nov 2013
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
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.
0 Comments
More Answers (0)
See Also
Categories
Find more on Implement C/C++ Code Using S-Function Builder in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!