MLUserFunction (C Function)

MLUserFunction has been replaced by WSUserFunction.

is a MathLink type that describes a function pointer to a function taking an MLINK argument with a return type of void.

Details

  • The function MLSetUserData() takes a MLUserFunction as its second argument. MathLink automatically calls the MLUserFunction at MLClose() time.
  • MLUserFunction 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);
}