WSUserData()
This feature is not supported on the Wolfram Cloud.

void * WSUserData(WSLINK link,WSUserFunction *fp)
returns the data object and function pointer installed by WSSetUserData().

DetailsDetails

  • WSUserData() is declared in the WSTP header file wstp.h.

ExamplesExamplesopen allclose all

Basic Examples  (1)Basic Examples  (1)

#include <stdlib.h>
#include "wstp.h"

typedef struct foo_ {
    int member;
} foo;


int main(int argc, char **argv)
{
    WSENV env;
    WSINK link;
    int error;
    foo *fobj;

    fobj = (foo *)malloc(sizeof(foo));
    if(fobj == (foo *)0)
        { /* unable to allocate memory for foo object */ }

    env = WSInitialize((WSEnvironmentParameter)0);
    if(env == (WSENV)0)
        { /* unable to initialize WSTP environment */ }

    link = WSOpenArgcArgv(env, argc, argv, &error);
    if(link == (WSINK)0 || error != WSEOK)
        { /* unable to create link object */ }

    WSSetUserData(link, (void *)fobj, (WSUserFunction)0);

    /* ... */

    fobj = WSUserData(link, (WSUserFunction *)0);

    free(fobj);

    WSClose(link);
    WSDeinitialize(env);

    return 0;
}