MLSetUserData (C Function)
MLSetUserData has been replaced by WSSetUserData.
void MLSetUserData(MLINK link,void* d,MLUserFunction f)
installs the users data object data and function f in link.
Details

- The object d is retrievable anytime using MLUserData().
- MathLink will automatically call the function f at MLClose() time with link as its argument.
- MLSetUserData() is declared in the MathLink header file mathlink.h.
Examples
Basic Examples (1)
#include <stdlib.h>
#include "mathlink.h"
typedef struct foo_
{
int member1;
} foo;
/* destroy a foo object retrieved from a link */
void c(MLINK lp)
{
foo *fobj;
fobj = MLUserData(lp, (MLUserFunction *)0);
if(fobj == (foo *)0) return;
free(foo);
}
/* allocate a foo object and store it in a link */
void f(MLINK lp)
{
foo *fobj;
fobj = (foo *)malloc(sizeof(foo));
if(fobj == (foo *)0)
{ /* error allocating space for foo object */ }
MLSetUserData(lp, (void *)fobj, c);
}