MLGetByteArray (C Function)

MLGetByteArray has been replaced by WSGetByteArray.

int MLGetByteArray(MLINK link,unsigned char **a,int **dims,char ***heads,int *d)

gets an array of 1-byte sized integers from the MathLink connection specified by link, storing the array in a, its dimensions in dims and its depth in d.

Details

  • The array a is laid out in memory like a C array declared as .
  • heads gives a list of character strings corresponding to the names of symbols that appear as heads at each level in the array.
  • MLGetByteArray() allocates memory which must be disowned by calling MLReleaseByteArray(). If MLGetByteArray() fails and the function's return value indicates an error, do not call MLReleaseByteArray() on the contents of a.
  • MLGetByteArray() returns immutable data.
  • MLGetByteArray() returns 0 in the event of an error, and a nonzero value if the function succeeds.
  • Use MLError() to retrieve the error code if MLGetByteArray() fails.
  • MLGetByteArray() is declared in the MathLink header file mathlink.h.

Examples

Basic Examples  (1)

#include "mathlink.h"

/* read a byte-sized integer array from a link */

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

    if(! MLGetByteArray(lp, &data, &dims, &heads, &d))
        {
            /* unable to read the integer array from lp */
            return;
        }

    /* ... */

    MLReleaseByteArray(lp, data, dims, heads, d);
}