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!

Respuestas (2)

Walter Roberson
Walter Roberson el 24 de Abr. de 2013
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.

Categorías

Más información sobre Startup and Shutdown en Centro de ayuda y File Exchange.

Preguntada:

el 24 de Abr. de 2013

Community Treasure Hunt

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

Start Hunting!

Translated by