This feature is not supported on the Wolfram Cloud.

is a WSTP 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.
  • WSAllocator() is declared in the WSTP header file wstp.h.

ExamplesExamplesopen allclose all

Basic Examples  (1)Basic Examples  (1)

#include <stdlib.h>
#include "wstp.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)
    WSENV env;
    WSLINK link;
    WSParameters p;
    int error;

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

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

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

    /* ... */


    return 0;
Translate this page: