This is the mail archive of the
libffi-discuss@sourceware.org
mailing list for the libffi project.
Re: return value buffer malloc()'ed vs alloca()'ed
- From: Anthony Green <green at redhat dot com>
- To: Andrew Haley <aph at redhat dot com>
- Cc: Anthony Green <green at moxielogic dot com>, Igor Bogomazov <ygrex at ygrex dot ru>, libffi-discuss at sourceware dot org
- Date: Tue, 8 Oct 2013 13:40:18 -0400 (EDT)
- Subject: Re: return value buffer malloc()'ed vs alloca()'ed
- Authentication-results: sourceware.org; auth=none
- References: <20131008101354 dot 43baeeeb at ygrex-mac> <CACxje58LTEpBiaUHQn6Bp=Puvmz-Sg7gReGrWfz2Nz-diZG4GA at mail dot gmail dot com> <5254428A dot 9080204 at redhat dot com>
We've had this discussion many times...
https://www.google.com/search?q=libffi+largest+integral+type&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a
particularly...
http://sourceware-org.1504.n7.nabble.com/closure-api-return-value-types-problem-td201402.html
I've written it off as a wart that we must live with (so, a documentation bug). But maybe somebody can demonstrate how to change it without impacting current users.
AG
----- Original Message -----
From: "Andrew Haley" <aph@redhat.com>
To: "Anthony Green" <green@moxielogic.com>
Cc: "Igor Bogomazov" <ygrex@ygrex.ru>, libffi-discuss@sourceware.org
Sent: Tuesday, October 8, 2013 1:36:10 PM
Subject: Re: return value buffer malloc()'ed vs alloca()'ed
On 10/08/2013 06:30 PM, Anthony Green wrote:
> The result
> buffer needs to be the largest native integral type on your system.
> Use a 64 bit long for rc instead of mallocing the exact return type
> size. You can pass it into ffi_call as &rc and simply cast it to an
> int at the end. I just checked the docs and it's definitely not
> clear
Hmmmmm. It's not so much unclear as completely wrong.
Andrew.