Variable Input on procedure - pass by value or pass by refer

T

Tricky

Guest
I have the following in my code:

type img_2d_ptr is access image_grey_2D_t;
type image_array_t is array(natural range <>) of img_2d_ptr;
shared variable PIP_IMAGES : image_array_t(PIP_REGISTERS'range) :=
read_PIP_images;

procedure destroy_images( variable x : in image_array_t ) is
begin
for i in x'range loop
DEALLOCATE( x(i) );
end loop;
end procedure destroy_images;

The pass by reference/value is quite important here, because I need to
actually make sure the images are actually deallocated, and it doesnt
deallocate just a copy of them.

Would it just be safer to ignore the input on the procedure and just
deallocate the PIP_IMAGES shared variable directly?
 
On 19 Mar, 15:58, Tricky <Trickyh...@gmail.com> wrote:
I have the following in my code:

type img_2d_ptr is access image_grey_2D_t;
type image_array_t is array(natural range <>) of img_2d_ptr;
shared variable PIP_IMAGES  : image_array_t(PIP_REGISTERS'range) :> read_PIP_images;

procedure destroy_images( variable x : in image_array_t ) is
begin
  for i in x'range loop
    DEALLOCATE( x(i) );
  end loop;
end procedure destroy_images;

The pass by reference/value is quite important here, because I need to
actually make sure the images are actually deallocated, and it doesnt
deallocate just a copy of them.

Would it just be safer to ignore the input on the procedure and just
deallocate the PIP_IMAGES shared variable directly?
Having just read that to myself, it must be pass by reference, else
the DEALLOCATE procedure itself wouldnt work!
 
On Mar 19, 8:59 am, Tricky <Trickyh...@gmail.com> wrote:
On 19 Mar, 15:58, Tricky <Trickyh...@gmail.com> wrote:





I have the following in my code:

type img_2d_ptr is access image_grey_2D_t;
type image_array_t is array(natural range <>) of img_2d_ptr;
shared variable PIP_IMAGES  : image_array_t(PIP_REGISTERS'range) :> > read_PIP_images;

procedure destroy_images( variable x : in image_array_t ) is
begin
  for i in x'range loop
    DEALLOCATE( x(i) );
  end loop;
end procedure destroy_images;

The pass by reference/value is quite important here, because I need to
actually make sure the images are actually deallocated, and it doesnt
deallocate just a copy of them.

Would it just be safer to ignore the input on the procedure and just
deallocate the PIP_IMAGES shared variable directly?

Having just read that to myself, it must be pass by reference, else
the DEALLOCATE procedure itself wouldnt work!- Hide quoted text -

- Show quoted text -
Shouldn't the parameter be an "inout" and not just "in" ?
 

Welcome to EDABoard.com

Sponsor

Back
Top