Function xsDeleteMachine

Free a xsMachine.

void xsDeleteMachine (
  scope xs.bindings.xsMachineRecord* the
);

The destructors of all the host objects are executed, and all the memory allocated by the machine is freed.

Parameters

NameDescription
theA machine

Examples

The following example illustrates the use of xsCreateMachine and xsDeleteMachine.

int main(int argc, char* argv[]) {
typedef struct {
int argc;
char** argv;
} xsContext;

void xsMainContext(xsMachine* theMachine, int argc, char* argv[])
{
xsContext* aContext;

aContext = malloc(sizeof(xsContext));
if (aContext) {
aContext->argc = argc;
aContext->argv = argv;
xsSetContext(theMachine, aContext);
xsSetContext(theMachine, NULL);
free(aContext);
}
else
fprintf(stderr, "### Cannot allocate context\n");
}

xsCreation aCreation = {
128 * 1024 * 1024,	/* initialChunkSize */
16 * 1024 * 1024, 	/* incrementalChunkSize */
4 * 1024 * 1024, 	/* initialHeapCount */
1 * 1024 * 1024,	/* incrementalHeapCount */
1024,			/* stack count */
2048+1024,		/* key count */
1993,			/* name modulo */
127			/* symbol modulo */
};
xsMachine* aMachine;

aMachine = xsCreateMachine(&aCreation, "machine", NULL);
if (aMachine) {
xsMainContext(aMachine, argc, argv);
xsDeleteMachine(aMachine);
}
else
fprintf(stderr, "### Cannot allocate machine\n");
return 0;
}