comp.lang.ada
 help / color / mirror / Atom feed
From: Robert Dewar <robert_dewar@my-deja.com>
Subject: RE: Variable length raw-byte data
Date: Wed, 13 Dec 2000 15:52:32 GMT
Date: 2000-12-13T15:52:32+00:00	[thread overview]
Message-ID: <9185vs$nh8$1@nnrp1.deja.com> (raw)
In-Reply-To: B6A1A9B09E52D31183ED00A0C9E0888C469942@nctswashxchg.nctswash.navy.mil

In article
<B6A1A9B09E52D31183ED00A0C9E0888C469942@nctswashxchg.
nctswash.navy.mil>,

> 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.

Well you sure missed the point here :-)

Of *course* you never allocate an instance of a
big array. in fact it is not a bad idea to add

  for big_string_ptr'storage_Size use 0;

to emphasize this. The ONLY way you create instances
of the pointer is by unchecked conversion.
>
> And again if you use a pointer to the constrained
> subtype, you only allocate what you need.

Again, you never do any allocations.
>
> 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.

Well remember that the case being discussed here
is one in which the bounds are not part of the value
in any case. If you know the bound BEFORE you look
at the value, then of course you can make a subtype
that is the right length, but this is not always
the case, the obvious example being a C-style
null-terminated string, and here of course, yes,
the program must be "kind" and make sure it does
not reference past the terminating zero byte.

> >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?

That's the point, you *can't* depend on C to do this.
And if you are importing the data from the C world,
you cannot depend on Ada to magically protect you
from inherently dangerous C data structures!


Sent via Deja.com
http://www.deja.com/



  reply	other threads:[~2000-12-13 15:52 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-12-13  2:56 Variable length raw-byte data Beard, Frank
2000-12-13 15:52 ` Robert Dewar [this message]
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