comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <rm.tsoh.plus-bug.bauhaus@maps.futureapps.de>
Subject: Re: Converting pointers to non nul-terminated C "strings" to Ada string
Date: Sun, 15 Feb 2009 18:44:15 +0100
Date: 2009-02-15T18:44:19+01:00	[thread overview]
Message-ID: <49985473$0$31337$9b4e6d93@newsspool4.arcor-online.net> (raw)
In-Reply-To: <bff0b129-cc3a-4d8a-8e83-6fc0fe601f1c@o36g2000yqh.googlegroups.com>

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.



  reply	other threads:[~2009-02-15 17:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-14  6:58 Converting pointers to non nul-terminated C "strings" to Ada string xorquewasp
2009-02-14  9:26 ` Dmitry A. Kazakov
2009-02-14 10:38   ` xorquewasp
2009-02-14 11:16     ` Dmitry A. Kazakov
2009-02-14 11:37       ` xorquewasp
2009-02-14  9:27 ` Hibou57 (Yannick Duchêne)
2009-02-14 10:41   ` xorquewasp
2009-02-15 17:44     ` Georg Bauhaus [this message]
2009-02-14 11:47   ` Jacob Sparre Andersen
2009-02-14 14:25     ` Hibou57 (Yannick Duchêne)
2009-02-14  9:28 ` sjw
2009-02-14  9:33 ` likai3g
replies disabled

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