%malloc() function

The %malloc() function allocates a memory block of size bytes and returns the address of this block.


var = (char*)%malloc(size)


The memory is freed by the %free() built-in. If the system fails to allocate memory, a null pointer is returned.

If the FlashBASIC program terminates, the space allocated by %malloc is not released automatically. This feature can be used to create static data, live across program executions. The TCL environ command uses this fact.

Memory allocated by %malloc can be freed by exiting the D3 process.


if ptr=0 then stop ’cannot allocate memory’