DEFINITION MODULE Storage; (* Standard dynamic storage management Derived from the Lilith Modula-2 system developed by the group of Prof. N. Wirth at ETH Zurich, Switzerland. Storage management for dynamic variables. Calls to the Modula-2 standard procedures NEW and DISPOSE are translated into calls to ALLOCATE and DEALLOCATE. The standard way to provide these two procedures is to import them from this module 'Storage'. *) FROM SYSTEM IMPORT ADDRESS; EXPORT QUALIFIED ALLOCATE, DEALLOCATE, Available, InstallHeap, RemoveHeap; PROCEDURE ALLOCATE (VAR a: ADDRESS; size: CARDINAL); (*- Allocate some dynamic storage. in: size number of bytes to allocate, out: a ADDRESS of allocated storage. The actual number of bytes allocated may be slightly greater than 'size', due to administrative overhead. If not enough space is available, the calling program is terminated with the status 'heapovf'. *) PROCEDURE DEALLOCATE (VAR a: ADDRESS; size: CARDINAL); (*- Release some dynamic storage. in: a ADDRESS of the area to release, size number of bytes to be released, out: a set to NIL. *) PROCEDURE Available (size: CARDINAL) : BOOLEAN; (*- Test whether some number of bytes could be allocated. in: size number of bytes out: TRUE if ALLOCATE(p,size) would succeed. *) PROCEDURE InstallHeap; (*- Used by the loader -*) PROCEDURE RemoveHeap; (*- Used by the loader -*) END Storage.