comp.lang.ada
 help / color / mirror / Atom feed
From: mheaney@ni.net (Matthew Heaney)
Subject: Re: pointers to unconstrained arrays
Date: 1997/11/16
Date: 1997-11-16T00:00:00+00:00	[thread overview]
Message-ID: <mheaney-ya023680001611972211100001@news.ni.net> (raw)
In-Reply-To: 346FC90F.3EEC@vsl.com.au


In article <346FC90F.3EEC@vsl.com.au>, Andrew Kelly <andrewk@vsl.com.au> wrote:

>procedure allocate_buffer (
>        low, high : in integer;
>        buffer_address : system.address;
>        buffer_ptr : out buffer_ptr_type) is

[snip]

>        -- return pointer to buffer     
>        buffer_ptr := buffer'access;
>end allocate_buffer;

You can't do this, and for a very good reason.  You're pointing to a
locally-declared buffer.

>
>
>
>-- unconstrained_array_ptr_test
>        my_buffer_ptr : buffer_ptr_type;
>
>begin 
>        allocate_buffer(1, 5, system.ItoA(16#B000#), my_buffer_ptr);

Why not do this

   Buffer : Buffer_Type (1 .. 5);
   for Buffer'Address use System.ItoA (16#B000#);
begin

and then refer to Buffer directly?  If you're going to call Allocate_Buffer
with hard-coded parameters, and declare a buffer access type to indirectly
refer to the buffer, you might as well just declare a buffer directly,
using the parameters you passed to the call.

--------------------------------------------------------------------
Matthew Heaney
Software Development Consultant
<mailto:matthew_heaney@acm.org>
(818) 985-1271




       reply	other threads:[~1997-11-16  0:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <346FC90F.3EEC@vsl.com.au>
1997-11-16  0:00 ` Matthew Heaney [this message]
1997-11-17  0:00   ` pointers to unconstrained arrays Keith Thompson
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox