External Interfaces Previous page   Next Page

Reference Pointers

Arguments that have more than one level of referencing (e.g., uint16 **) are referred to here as reference pointers. In MATLAB, these argument types are named with the suffix PtrPtr (for example, uint16PtrPtr). See the output of libfunctionsview or methods -full for examples of this type.

When calling a function that takes a reference pointer argument, you can use a reference argument instead and MATLAB will convert it to the reference pointer. For example, the external allocateStruct function expects a c_structPtrPtr argument:

Here is the C function:

Although the prototype says that a c_structPtrPtr is required, you can use a c_structPtr and let MATLAB do the second level of conversion. Create a reference to an empty structure argument and pass it to allocateStruct:

When you are done, return the memory that you had allocated:


Previous page  Creating References Calling C and Fortran Programs from MATLAB Next page

© 1994-2005 The MathWorks, Inc.