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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,f0d9db8126fd91cb X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!l16g2000yqo.googlegroups.com!not-for-mail From: xorquewasp@googlemail.com Newsgroups: comp.lang.ada Subject: Re: Converting pointers to non nul-terminated C "strings" to Ada string Date: Sat, 14 Feb 2009 02:38:35 -0800 (PST) Organization: http://groups.google.com Message-ID: <6948ef0c-ce70-4330-ba2f-313d9b6ff6d5@l16g2000yqo.googlegroups.com> References: <9o91prwivma0$.1e4dd833ypxy1.dlg@40tude.net> NNTP-Posting-Host: 81.86.41.187 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1234607915 31024 127.0.0.1 (14 Feb 2009 10:38:35 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 14 Feb 2009 10:38:35 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: l16g2000yqo.googlegroups.com; posting-host=81.86.41.187; posting-account=D9GNUgoAAAAmg7CCIh9FhKHNAJmHypsp User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.5) Gecko/2008122011 Iceweasel/3.0.5 (Debian-3.0.5-1),gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:4602 Date: 2009-02-14T02:38:35-08:00 List-Id: 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).