292 of 323
ZBasic System Library 282 ZX Microcontroller Family System.Free Type Subroutine Invocation System.Free(addr) Parameter Method Type Description addr ByVal UnsignedInteger The address of the block to free. Discussion This subroutine returns a block of allocated memory to the heap so that it may be later re-used. The addr parameter must be the value returned by an earlier call to System.Alloc() that has not yet been freed. Invoking this subroutine with addr equal to 0 is a special case that is benign. This function and its companion, System.Alloc(), must be used with great care. If System.Free() is called with a non-zero value that is not one returned by System.Alloc() or a value that has already been freed, the heap management data structures will almost certainly be corrupted and future allocations will likely fail. It is a good practice to set an address to zero after it has been freed as illustrated in the example below. Example Dim addr as UnsignedInteger addr = System.Alloc(50) [other code here that uses the allocated block] Call System.Free(addr) addr = 0 Compatibility This routine is not available in BasicX compatibility mode. See Also System.Alloc