NILis returned. The memory is initialised to zero in each byte, and taken from any available store (Fast or Chip memory, in that order of preference). When you've finished with this memory you can use
Disposeto free it for use elsewhere in your program. You don't have to
Disposewith memory you allocated with
Newbecause your program will automatically free it when it terminates. This is not true for memory allocated using the normal Amiga system routines.
Newexcept that if the memory could not be allocated then the exception
"MEM"is raised (and so, in this case, the function does not return). See 13 Exception Handling.
NewRexcept that the type of memory (Fast or Chip) to be allocated can be specified using flags. The flags are defined in the module `exec/memory' (see 12.2 Amiga System Modules). See the Rom Kernel Reference Manual (Libraries) for details about the system function
AllocMemwhich uses these flags in the same way.
As useful example, here's a small program which allocates some cleared (i.e., zeroed) Chip memory.
MODULE 'exec/memory' PROC main() DEF m m:=NewM(20, MEMF_CHIP OR MEMF_CLEAR) WriteF('Allocation succeeded, m = $\h\n', m) EXCEPT IF exception="NEW" THEN WriteF('Failed\n') ENDPROC
NewM. You should rarely need to use this function because the memory is automatically freed when the program terminates.
String(see 9.5.2 String functions) or
List(see 9.5.4 List functions). Again, you should rarely need to use this function because the memory is automatically freed when the program terminates.
NewRexcept it uses a very fast, recycling method of allocating memory. The memory allocated using
FastNewis, as ever, deallocated automatically at the end of a program, and can be deallocated before then using
FastDispose. Note that only
FastDisposecan be used and that it differs slightly from the
DisposeLinkfunctions (you have to specify the number of bytes again when deallocating).
FastNew. The bytes parameter must be the same as the bytes used when the memory was allocated with
FastNew, but the benefit is much faster allocation and deallocation, and generally more efficient use of memory.
Exitroutine which should never be used in an E program. This is the only safe way of terminating a program, other than reaching the (logical) end of the
mainprocedure (which is by far the most common way!).
TRUEif control-C has been pressed since the last call, and
FALSEotherwise. This is really sensible only for programs started from the Shell/CLI.
TRUEif your Kickstart revision is at least that given by expression, and
FALSEotherwise. For instance,
KickVersion(37)checks whether you're running with Kickstart version 37 or greater (i.e., AmigaDOS 2.04 and above).
Go to the Next or Previous section, the Detailed Contents, or the Amiga E Encyclopedia.