WSGetByteArray (C Function)

int WSGetByteArray(WSLINK link,unsigned char **a,int **dims,char ***heads,int *d)

gets an array of 1-byte sized integers from the WSTP 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 .
  • heads gives a list of character strings corresponding to the names of symbols that appear as heads at each level in the array.
  • WSGetByteArray() allocates memory which must be disowned by calling WSReleaseByteArray(). If WSGetByteArray() fails and the function's return value indicates an error, do not call WSReleaseByteArray() on the contents of a.
  • WSGetByteArray() returns immutable data.
  • WSGetByteArray() returns 0 in the event of an error, and a nonzero value if the function succeeds.
  • Use WSError() to retrieve the error code if WSGetByteArray() fails.
  • WSGetByteArray() is declared in the WSTP header file wstp.h.


Basic Examples  (1)

#include "wstp.h"

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

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

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

    /* ... */

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