External Interfaces/API Reference |
Allocate dynamic memory using the MATLAB memory manager
Fortran Syntax
Arguments
n
Number of elements to allocate. This must be a nonnegative number.
size
Number of bytes per element.
Returns
A pointer to the start of the allocated dynamic memory, if successful. If unsuccessful in a stand-alone (nonMEX-file) application, mxCalloc
returns 0. If unsuccessful in a MEX-file, the MEX-file terminates and control returns to the MATLAB prompt.
mxCalloc
is unsuccessful when there is insufficient free heap space.
Description
The MATLAB memory management facility maintains a list of all memory allocated by mxCalloc
(and by the mxCreate
calls). The MATLAB memory management facility automatically frees (deallocates) all of a MEX-file's parcels when control returns to the MATLAB prompt.
By default, in a MEX-file, mxCalloc
generates nonpersistent mxCalloc
data. In other words, the memory management facility automatically deallocates the memory as soon as the MEX-file ends. When you finish using the memory allocated by mxCalloc
, call mxFree
. mxFree
deallocates the memory.
mxCalloc
works differently in MEX-files than in stand-alone MATLAB applications. In MEX-files, mxCalloc
automatically
n
elements.
n
elements to 0.
In stand-alone MATLAB applications, the MATLAB memory manager is not used.
See Also
mxCalcSingleSubscript | mxClassIDFromClassName |