Alternative to 'clear' or 'clearvars' in standalone C code generation?
古いコメントを表示
I've searched quite extensively for how to convert a call to clear variables from my matlab code to standalone C (using matlab compiler). Is there an alternative function that can be used?
Thank you!
回答 (2 件)
Walter Roberson
2013 年 4 月 24 日
1 投票
You cannot clear variables in C.
Variables local to a C function will be released when the function returns. Array variables in C functions cannot be resized.
C does have the ability to create storage (but not variable names) dynamically using malloc(); the storage (but not the variable name) for those can be returned by using free(). This is, though, unlikely to remove that storage from the program: it just returns it to a pool of available storage allocated to the process, to be used next time the process uses malloc().
If you have a need to allocate memory dynamically and have it truly return to the operating system (released by the process) when you are done with it, then you are getting into operating-system behaviour rather than C behaviour. I do not know what operating system mechanisms are preferred for that in MS WIndows.
カテゴリ
ヘルプ センター および File Exchange で Startup and Shutdown についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!