OBSOLETE WSTP C FUNCTION

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

has been replaced by .

void * MLUserData(MLINK link,MLUserFunction *fp)
returns the data object and function pointer installed by MLSetUserData().

DetailsDetails

  • MLUserData() is declared in the MathLink header file mathlink.h.

ExamplesExamplesopen allclose all

Basic Examples  (1)Basic Examples  (1)

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

typedef struct foo_ {
    int member;
} foo;


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

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

    env = MLInitialize((MLEnvironmentParameter)0);
    if(env == (MLENV)0)
        { /* unable to initialize MathLink environment */ }

    link = MLOpenArgcArgv(env, argc, argv, &error);
    if(link == (MLINK)0 || error != MLEOK)
        { /* unable to create link object */ }

    MLSetUserData(link, (void *)fobj, (MLUserFunction)0);

    /* ... */

    fobj = MLUserData(link, (MLUserFunction *)0);

    free(fobj);

    MLClose(link);
    MLDeinitialize(env);

    return 0;
}