comp.lang.ada
 help / color / mirror / Atom feed
From: "Beard, Frank" <beardf@spawar.navy.mil>
To: "'comp.lang.ada@ada.eu.org'" <comp.lang.ada@ada.eu.org>
Subject: RE: Variable length raw-byte data
Date: Tue, 12 Dec 2000 21:56:14 -0500
Date: 2000-12-12T21:56:14-05:00	[thread overview]
Message-ID: <B6A1A9B09E52D31183ED00A0C9E0888C469942@nctswashxchg.nctswash.navy.mil> (raw)

>The important thing is to NEVER use pointers to unconstrained
>arrays in such a case. this is asking for non-portable, peculiar
>behavior.

That's exactly why my example contained a pointer to the constrained
subtype.

> A good type to use in this case is what we in GNAT-land call
> big arrays:
>
>   type byte is mod 2 ** 8;
>
>   type memory is array (natural) of byte;
>   type memptr is access memory;

So you're going to allocate 2GB to handle what might
be only 10 bytes (or even 1K or 10K).  That should
work well on a dedicated processor with 64 K of memory.

And again if you use a pointer to the constrained subtype,
you only allocate what you need. 

Or are you saying, you will be kind and make sure you
don't go beyond the length value returned, instead of
letting Ada constraint checking make sure you don't do it.

>Now it is almost certainly safe to use address_to_access
>conversions to go between address and memptr.
>
>Of course you have to be careful not to access the array
>out of bounds, but that's going to be up to the calling
>program anyway if the bounds don't come built in :-)

And you're going to depend on C to do this?




             reply	other threads:[~2000-12-13  2:56 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-12-13  2:56 Beard, Frank [this message]
2000-12-13 15:52 ` Variable length raw-byte data Robert Dewar
2000-12-13 18:23   ` Larry Kilgallen
2000-12-13 19:26     ` Robert Dewar
  -- strict thread matches above, loose matches on Subject: below --
2000-12-13 20:39 Beard, Frank
2000-12-14 13:30 ` Robert Dewar
2000-12-12 21:11 Beard, Frank
2000-12-12 21:00 Beard, Frank
2000-12-13 15:48 ` David Botton
2000-12-13 15:51   ` Lutz Donnerhacke
2000-12-13 19:34     ` Robert Dewar
2000-12-14  8:54       ` Lutz Donnerhacke
2000-12-13 23:10   ` Jeff Carter
2000-12-12  3:30 Beard, Frank
2000-12-12  5:54 ` tmoran
2000-12-11 19:38 Julian Morrison
2000-12-12  5:19 ` Jeff Carter
2000-12-13  0:50 ` Robert Dewar
2000-12-13  8:56   ` Tristan Gingold
replies disabled

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