comp.lang.ada
 help / color / mirror / Atom feed
From: xorquewasp@googlemail.com
Subject: Re: Converting pointers to non nul-terminated C "strings" to Ada string
Date: Sat, 14 Feb 2009 02:38:35 -0800 (PST)
Date: 2009-02-14T02:38:35-08:00	[thread overview]
Message-ID: <6948ef0c-ce70-4330-ba2f-313d9b6ff6d5@l16g2000yqo.googlegroups.com> (raw)
In-Reply-To: 9o91prwivma0$.1e4dd833ypxy1.dlg@40tude.net



Dmitry A. Kazakov wrote:
>
> I would suggest to use Interfaces.C.Pointers instead of
> Interfaces.C.Strings:
>

That does mean going outside of the RM, which is a bit unfortunate.
I'll keep it in mind, however.

>
> Are you sure that get_data is char **, int * rather than void **, size_t *?
> In the latter case I would consider Storage_Array instead of String on the
> Ada side.

Well, the C function parameters are defined as char **, int * but do
have
a meaning closer to void **, size_t *. Storage_Array is probably more
appropriate, as you state. That still leaves the question of
converting from
an address or access type to an unconstrained array (can't pass an
unconstrained array or access to an unconstrained array to C code).

>
> Yet another issue. It is not so frequent that C API allocated a data buffer
> and returned it to the caller, as your example suggests.

In this case, the library remains in complete control of the memory.

(It's one of the OpenSSL bio.h functions, if anyone's really curious).



  reply	other threads:[~2009-02-14 10:38 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 [this message]
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
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