From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,35ee0472de38e833 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2000-12-12 19:00:00 PST Path: supernews.google.com!sn-xit-02!supernews.com!news.gv.tsc.tdk.com!news.iac.net!newsgate.cistron.nl!news.tele.dk!213.56.195.71!fr.usenet-edu.net!usenet-edu.net!enst!enst.fr!not-for-mail From: "Beard, Frank" Newsgroups: comp.lang.ada Subject: RE: Variable length raw-byte data Date: Tue, 12 Dec 2000 21:56:14 -0500 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: avanie.enst.fr 976676288 86123 137.194.161.2 (13 Dec 2000 02:58:08 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Wed, 13 Dec 2000 02:58:08 +0000 (UTC) To: "'comp.lang.ada@ada.eu.org'" Return-Path: X-Mailer: Internet Mail Service (5.5.2448.0) Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0beta5 Precedence: bulk List-Id: comp.lang.ada mail<->news gateway Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: supernews.google.com comp.lang.ada:3038 Date: 2000-12-12T21:56:14-05:00 >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?