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,a71fc4911021ed50 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Alex R. Mosteo" Newsgroups: comp.lang.ada Subject: Re: Returning data from Ada to C Date: Wed, 04 May 2005 15:58:34 +0200 Message-ID: <4278D50A.5010408@mailinator.com> References: <1115164192.585409.163780@z14g2000cwz.googlegroups.com> <9vYde.5480$GQ5.3731@newsread1.news.pas.earthlink.net> <4f1a9$4278d210$cf702d0d$18288@PRIMUS.CA> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net +VIxuAbKVNrvQvOCMY7pmwFKFzxm7ymYXNOCnZ3z+iGy9aaN0= User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) X-Accept-Language: en-us, en In-Reply-To: <4f1a9$4278d210$cf702d0d$18288@PRIMUS.CA> Xref: g2news1.google.com comp.lang.ada:10912 Date: 2005-05-04T15:58:34+02:00 List-Id: Igor Khavkine wrote: > Thanks for the quick reply. > > On 2005-05-04, Jeffrey Carter wrote: > >>igor.kh@gmail.com wrote: >> >>> /* BTW, is it OK to use Ada allocated memory after `adafinal()'? */ >> >>No. > > > Ok, that's good to know. Also, will I be able to free Ada allocated > memory with the standard C library `free()'? For example, what do I do if > I want to free the storage pointed to by `solvec' below? I'd export a new Ada procedure for this purpose, so you keep all memory management in the Ada side. Even if gnat uses malloc internally I guess this is safer. > > >>> sols : C_Double_Array; -- This is probably wrong, but `sols' will be >>> -- a C_Double_Array of some size. >> >>This won't compile. C_Double_Array is an unconstrained array type. >>Objects must be constrained. You probably need >> >>Sols : aliased C_Double_Array (> >> >>>-- Now I want to return `rcnt' and `sols' >>> rcnt := rc; -- This is the easy part. >>> solvec := ??? -- What goes here? >> >>Solvec := Sols'Unchecked_Access; > > > Great! Now, what type will `Solvec' have? I presume that GNAT will bark at > me if I use the wrong type. > > Thanks. > > Igor