This is documentation for Mathematica 6, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
MathLink C Function


int MLGetIntegerArray(MLINK link, int **a, long **dims, char ***heads, long *d)
gets an array of integers from the MathLink connection specified by link, storing the array in a, its dimensions in dims and its depth in d.
  • The array a is laid out in memory like a C array declared as int a[m][n]....
  • heads gives a list of character strings corresponding to the names of symbols that appear as heads at each level in the array.
  • MLGetIntegerArray() allocates memory which must be disowned by calling MLDisownIntegerArray(). If MLGetIntegerArray() fails and the function's return value indicates an error, do not call MLDisownIntegerArray() on the contents of a.
  • External programs should not modify the arrays generated by MLGetIntegerArray().
  • MLGetIntegerArray() returns 0 in the event of an error, and a nonzero value if the function succeeds.
  • Use MLError() to retrieve the error code if MLGetIntegerArray() fails.
#include "mathlink.h"

/* read an array of integers from a link */

void f(MLINK lp)
    int *data;
    long *dims;
    char **heads;
    long d;

    if(! MLGetIntegerArray(lp, &data, &dims, &heads, &d))
            /* unable to read the integer array */

    /* ... */

    MLDisownIntegerArray(lp, data, dims, heads, d);