Data objects of the type access are pointers to dynamically allocated scalar or complex data objects. They are similar to pointers in other programming languages (C or Pascal). Only a variable can be declared of type access.
Syntax:
type ptr_type_name is access type_name;
In order to allocate and deallocate memory for an access type variable
two operators are defined:
If the access type variable is pointing to an unconstrained type like string then the restriction must be defined within the function call new.
Example:
type CELL; incomplete type
type LINK is access CELL; access type
type CELL is full type declaration for CELL
record
VALUE : integer;
NEXTP : LINK;
end;
variable HEAD, TEMP : LINK; pointer to CELL
...
TEMP := new CELL'(0, null); new data object with initial values
for I in 1 to 5 loop
HEAD := new CELL; additional objects
HEAD.VALUE := I; access to record element
HEAD.NEXTP := TEMP;
TEMP := HEAD;
end loop;
...
deallocate(TEMP); free the memory
allocate new memory
new CELL; new object
new CELL'(I, TEMP); ... with initial values
... with the required range restriction
new BIT_VECTOR (15 downto 0); by specifying an index range
new BIT_VECTOR'("
001101110"
); by assigning an initial value