comp.lang.ada
 help / color / mirror / Atom feed
* Re: pointers to unconstrained arrays
       [not found] <346FC90F.3EEC@vsl.com.au>
@ 1997-11-16  0:00 ` Matthew Heaney
  1997-11-17  0:00   ` Keith Thompson
  0 siblings, 1 reply; 2+ messages in thread
From: Matthew Heaney @ 1997-11-16  0:00 UTC (permalink / raw)



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




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: pointers to unconstrained arrays
  1997-11-16  0:00 ` pointers to unconstrained arrays Matthew Heaney
@ 1997-11-17  0:00   ` Keith Thompson
  0 siblings, 0 replies; 2+ messages in thread
From: Keith Thompson @ 1997-11-17  0:00 UTC (permalink / raw)



Matthew Heaney (mheaney@ni.net) wrote:
[...]
> Why not do this
> 
>    Buffer : Buffer_Type (1 .. 5);
>    for Buffer'Address use System.ItoA (16#B000#);
> begin
> 
> and then refer to Buffer directly?

Good idea, except that there's no ItoA function in System (though some
implementations may (unwisely, IMHO) provide such a function).

Try System.Storage_Elements.To_Address.

-- 
Keith Thompson (The_Other_Keith) kst@cts.com <*>
^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H
San Diego, California, USA
"Simba, you have forgotten me.  I am your father.  This is CNN." -- JEJ




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1997-11-17  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <346FC90F.3EEC@vsl.com.au>
1997-11-16  0:00 ` pointers to unconstrained arrays Matthew Heaney
1997-11-17  0:00   ` Keith Thompson

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