T
Tricky
the following code works, and Im just making sure that it is garanteed
to work and Im not just hitting some luck that the pointer address has
remained constant this time only. Look at the following code:
process
type a_p_t is access integer;
variable ap1 : a_p_t;
variable ap2 : a_p_t;
begin
ap1 := new integer;
ap1.all := 1;
ap2 := ap1;
DEALLOCATE(ap1);
ap1 := new integer;
ap1.all := 5;
echo(integer'image(ap2.all) & LF);
wait;
end process;
......
I thought that ap2 would hold be a copy of the origional ap1,
therefore when new memory was alocated you couldnt garantee that ap2
would now point to the correct place, and in this case when I run it
Im just lucky ap1 doesnt change when a new integer is created?. or Is
it actually the case that the address will hold valid for ever, and
ap2 will now always point to the value inside ap1.
am I correct in thinking, that if I assign ap1 to something else, ap2
then wont work?
to work and Im not just hitting some luck that the pointer address has
remained constant this time only. Look at the following code:
process
type a_p_t is access integer;
variable ap1 : a_p_t;
variable ap2 : a_p_t;
begin
ap1 := new integer;
ap1.all := 1;
ap2 := ap1;
DEALLOCATE(ap1);
ap1 := new integer;
ap1.all := 5;
echo(integer'image(ap2.all) & LF);
wait;
end process;
......
I thought that ap2 would hold be a copy of the origional ap1,
therefore when new memory was alocated you couldnt garantee that ap2
would now point to the correct place, and in this case when I run it
Im just lucky ap1 doesnt change when a new integer is created?. or Is
it actually the case that the address will hold valid for ever, and
ap2 will now always point to the value inside ap1.
am I correct in thinking, that if I assign ap1 to something else, ap2
then wont work?