Pristine Ack-5.5
[Ack-5.5.git] / lang / m2 / libm2 / Storage.def
1 DEFINITION MODULE Storage;
2 (*
3   Module:       Dynamic storage allocation
4   From:         "Programming in Modula-2", 3rd, corrected edition, by N. Wirth
5   Version:      $Id: Storage.def,v 1.5 1994/06/24 12:49:44 ceriel Exp $
6 *)
7
8 (*
9   Wirth's 3rd edition certainly is confusing: mostly it uses Allocate, but
10   the module at the end of the book defines ALLOCATE. To avoid problems,
11   I included them both.
12 *)
13
14         FROM SYSTEM IMPORT ADDRESS;
15
16         PROCEDURE ALLOCATE(VAR a : ADDRESS; size : CARDINAL);
17         (* Allocate an area of the given size and return the address
18            in "a". If no space is available, the calling program is
19            killed.
20         *)
21
22         PROCEDURE Allocate(VAR a : ADDRESS; size : CARDINAL);
23         (* Identical to ALLOCATE *)
24
25         PROCEDURE DEALLOCATE(VAR a : ADDRESS; size : CARDINAL);
26         (* Free the area at address "a" with the given size. The area
27            must have been allocated by "ALLOCATE", with the same size.
28         *)
29
30         PROCEDURE Deallocate(VAR a : ADDRESS; size : CARDINAL);
31         (* Identical to DEALLOCATE *)
32
33         PROCEDURE Available(size : CARDINAL) : BOOLEAN;
34         (* Return TRUE if a contiguous area with the given size could be
35            allocated.
36            Notice that this only indicates if an ALLOCATE of this size
37            would succeed, and that it gives no indication of the total
38            available memory.
39         *)
40
41 END Storage.