MLAllocator has been replaced by WSAllocator.

is a MathLink type that describes a function pointer to a function taking an unsigned long argument and returning a void * that implements a memory allocator.


  • The memory allocator function must be thread-safe.
  • On 64-bit Windows platforms the allocator takes an unsigned __mlint64 as an argument.
  • MLAllocator() is declared in the MathLink header file mathlink.h.


Basic Examples  (1)

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

/* AppAllocator implements a custom memory allocator */
void * AppAllocator(unsigned long size)
    return malloc(size);

/* AppDeallocator implements a custom memory deallocator */
void AppDeallocator(void *m)

int main(int argc, char **argv)
    MLENV env;
    MLINK link;
    MLParameters p;
    int error;

    MLSetAllocParameter((char *)p, AppAllocator, AppDeallocator);

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

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

    /* ... */


    return 0;

See Also

MLDeallocator()  MLSetAllocParameter()  MLAllocParameter()