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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,f0d9db8126fd91cb X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news3.google.com!feeder.news-service.com!border1.nntp.ams.giganews.com!nntp.giganews.com!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Sun, 15 Feb 2009 18:44:15 +0100 From: Georg Bauhaus Reply-To: rm.tsoh+bauhaus@maps.futureapps.de User-Agent: Thunderbird 2.0.0.19 (Windows/20081209) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Converting pointers to non nul-terminated C "strings" to Ada string References: <6334ebd3-ca8d-4f1c-b96a-b49c20650d31@v15g2000yqn.googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <49985473$0$31337$9b4e6d93@newsspool4.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 15 Feb 2009 18:44:19 CET NNTP-Posting-Host: 3aa67cda.newsspool4.arcor-online.net X-Trace: DXC=iJ48?LLK2ocIkjb;<8iR=a4IUKH_hKQDKiQ7h xorquewasp@googlemail.com wrote: > Yannick Duch�ne Hibou57 wrote: >> A dirty thing which comes into my mind : when you write >> >> procedure memory_data >> (data : out CS.chars_ptr; >> size : out C.int); >> >> you may doing some assumption about the the compiler's generated code. >> In my humble opinion, pointers in C declarations should be mapped to >> access types in Ada. There is nothing I know which assert that an Ada >> implementation must use access types to implement out parameters. > > I may indeed. In most cases, I would use access types. I do extremely > heavy unit testing and haven't found a compiler/OS/arch combo where > the > above example doesn't work correctly, however. > >> To know how to properly handle this, the first requirements is to >> exactly know what does datas stands for. > > It's strictly a binary blob - the output of an encryption function. Some of the issues are adressed in "Accessing Memory as a String", http://www.adapower.com/index.php?Command=Class&ClassID=Advanced&CID=213 The article answers the question, "How do I access a chunck of memory as an Ada string with out moving or copying the data in Ada95?" Maybe you can use the size parameter for specifying an index subtype that porperly constrains the string.