basic.%malloc
Allocates memory.
Syntax
variable=(char*)%malloc( size )
Description
allocates a memory block of 'size' bytes and returns the address of this block.
The memory is freed by the '%free()' built-in. If the system fails to allocate memory, a NULL pointer is returned.
If the Pick/BASIC program terminates, the malloc'ed space is not released automatically. This feature can be used to create 'static' data, live across program executions. The TCL command 'environ' uses this fact.
'malloc'ed' memory may be 'free'd' by 'exit'ing the Pick process.
Example
ptr=(char*)%malloc( 2048 )
if ptr=0 then stop 'cannot allocate memory'
See Also
User Comments
What do you think?
Share your experience or ask a question by using the form below.
Login to leave your comments.
