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 MLGetIntegerList(MLINK link, int **a, long *n)
gets a list of integers from the MathLink connection specified by link, storing the integers in the array a and the length of the list in n.
  • MLGetIntegerList() allocates memory for the array of integers. You must call MLDisownIntegerList() to disown this memory. If MLGetIntegerList() fails and the function's return value indicates an error, do not call MLDisownIntegerList() on the contents of a.
  • MLGetIntegerList() returns immutable data.
  • MLGetIntegerList() returns 0 in the event of an error, and a nonzero value if the function succeeds.
  • Use MLError() to retrieve the error code if MLGetIntegerList() fails.
  • MLGetIntegerList() is declared in the MathLink header file mathlink.h.
#include "mathlink.h"

/* read a list of integers from a link */

void f(MLINK lp)
    int *data;
    long length;

    if(! MLGetIntegerList(lp, &data, &length))
            /* unable to read the integer list from lp */

    /* ... */

    MLDisownIntegerList(lp, data, length);