Using the C Math Library    

Function Template

You can use the template code below as the basis for writing functions that use the library's automated memory management. You can find the general function template and a main routine template in <matlab>/extern/examples/cmath/mem_mgt_func_template.c and mem_mgt_main_template.c respectively where <matlab> represents the top-level directory of your installation.

This function template takes one array output argument, two array input arguments, and returns an array. Your functions will, of course, vary the number of input and output arguments.

Notice how mlfEnterNewContext() and mlfRestorePreviousContext() operate on the array arguments passed to FunctionName. mlfReturnValue() manipulates the array returned from FunctionName.

Main Routine Template

The template for the main() routine is different from the general template because main() does not take any array input or output arguments or return an array. Passing 0 as an argument to mlfEnterNewContext() and mlfRestorePreviousContext() indicates that main() has no output and input array arguments. A call to mlfReturnValue() is not required.


 Using Automated Memory Management Enabling Memory Management