blob: 24bf8537896f531dabc665bf7ec21b12b63d87d8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
(* Library module defined by the International Standard
Information technology - programming languages
BS ISO/IEC 10514-1:1996E Part 1: Modula-2, Base Language.
Copyright ISO/IEC (International Organization for Standardization
and International Electrotechnical Commission) 1996-2021.
It may be freely copied for the purpose of implementation (see page
707 of the Information technology - Programming languages Part 1:
Modula-2, Base Language. BS ISO/IEC 10514-1:1996). *)
DEFINITION MODULE Storage;
(* Facilities for dynamically allocating and deallocating storage *)
IMPORT SYSTEM;
PROCEDURE ALLOCATE (VAR addr: SYSTEM.ADDRESS; amount: CARDINAL);
(* Allocates storage for a variable of size amount and assigns
the address of this variable to addr. If there is insufficient
unallocated storage to do this, the value NIL is assigned to addr.
*)
PROCEDURE DEALLOCATE (VAR addr: SYSTEM.ADDRESS; amount: CARDINAL);
(* Deallocates amount locations allocated by ALLOCATE for
the storage of the variable addressed by addr and assigns
the value NIL to addr.
*)
PROCEDURE REALLOCATE (VAR addr: SYSTEM.ADDRESS; amount: CARDINAL);
(* Attempts to reallocate, amount of storage. Effectively it
calls ALLOCATE, copies the amount of data pointed to by
addr into the new space and DEALLOCATES the addr.
This procedure is a GNU extension.
*)
TYPE
StorageExceptions = (
nilDeallocation, (* first argument to DEALLOCATE is NIL *)
pointerToUnallocatedStorage, (* storage to deallocate not allocated by ALLOCATE *)
wrongStorageToUnallocate (* amount to deallocate is not amount allocated *)
);
PROCEDURE IsStorageException (): BOOLEAN;
(* Returns TRUE if the current coroutine is in the exceptional
execution state because of the raising of an exception from
StorageExceptions; otherwise returns FALSE.
*)
PROCEDURE StorageException (): StorageExceptions;
(* If the current coroutine is in the exceptional execution
state because of the raising of an exception from
StorageExceptions, returns the corresponding
enumeration value, and otherwise raises an exception.
*)
END Storage.
|