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 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED.2uCIJahv+a4XEBqttj5Vkw.user.gioia.aioe.org!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Coding access to a C's pointer - pointer Date: Sat, 6 Jun 2020 19:01:40 +0200 Organization: Aioe.org NNTP Server Message-ID: References: NNTP-Posting-Host: 2uCIJahv+a4XEBqttj5Vkw.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.8.1 Content-Language: en-US X-Notice: Filtered by postfilter v. 0.9.2 Xref: reader01.eternal-september.org comp.lang.ada:58986 Date: 2020-06-06T19:01:40+02:00 List-Id: On 06/06/2020 18:23, Bob Goddard wrote: > I'm trying to shoehorn net-snmp into an Ada conversion and I've hit a roadblock. > > snmp_synch_response requires a pointer to a pointer: > snmp_synch_response(netsnmp_session *, netsnmp_pdu *, netsnmp_pdu **) > Just how the heck do you code that? You can't just declare a System.Address. That depends on the semantics because in C you cannot tell in from out. Assuming that snmp_synch_response returns a pointer to PDU and that netsnmp_session and netsnmp_pdu are record types: type netsnmp_pdu_Ptr is access all netsnmp_pdu; paragma Convention (C, netsnmp_pdu_Ptr); procedure snmp_synch_response ( Session : netsnmp_session; Request : netsnmp_pdu; Response : out netsnmp_pdu_Ptr -- Who manages the target? ); You must carefully read the documentation and probably the sources to determine who manages the returned object. Some libraries return pointers to internally allocated and freed memory others require the caller to deallocate the object at the returned point. C is a mess. > Would I need to drop into C and handle it there? P.S. Why do not you implement SNMP instead of using alien library? SNMP is not rocket science. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de