This is the mail archive of the
libffi-discuss@sourceware.org
mailing list for the libffi project.
Re: shallow copying in ffi_prep_cif
- From: Dan Witte <dwitte at mozilla dot com>
- To: Tom Dalling <tom dot dalling at gmail dot com>
- Cc: libffi-discuss at sourceware dot org
- Date: Tue, 30 Mar 2010 10:02:41 -0700 (PDT)
- Subject: Re: shallow copying in ffi_prep_cif
----- "Tom Dalling" <tom.dalling@gmail.com> wrote:
> On 31/03/2010, at 2:31 AM, Dan Witte wrote:
> > ----- "Tom Dalling" <tom.dalling@gmail.com> wrote:
> >> Is this is the intended behaviour? I just assumed that
> ffi_prep_cif
> >> and ffi_prep_closure_loc would do a deep copy.
> >
> > Yeah, you need to keep them both alive for the lifetime of the
> closure. I remember reading about this in the README, or the info
> page, or something -- does it not specify?
>
> Thanks for your help. I had a look through the README and info pages
> again, but I don't think it gets a mention. The info page actually has
> an example that uses stack allocated variables, which is how I got
> tripped up.
Mmm, you're right. I think I figured out the lifetime bit by reading closures.c itself.
If you want to write a patch to update the docs appropriately, I'm sure Anthony would take it :)
Dan.