Call Reentrant Code in a Single-Threaded Environment
To call reentrant code in a single-threaded environment, create
a main
function that:
Includes the header file
primary_function_name
.h.Allocates memory for the global memory allocation structure
primary_function_name
StackData
.If the algorithm uses persistent or global data, allocates memory for the global structure
primary_function_name
PersistentData
.Calls these functions:
primary_function_name
_initialize
.primary_function_name
.primary_function_name
_terminate
.
When you convert a MATLAB® function to a C/C++ library function or a C/C++ executable, MATLAB Coder™ generates two housekeeping functions. Call these housekeeping functions in the code that calls the generated C/C++ function. For more information, see Deploy Generated Code.
Frees the memory used for global structures.