This is the mail archive of the libffi-discuss@sourceware.org mailing list for the libffi project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: shallow copying in ffi_prep_cif


----- "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?

> Also, when it comes to freeing the memory, is there anything wrong
> with doing the following?
> 
> free(closure->cif->arg_types);
> free(closure->cif);
> ffi_closure_free(closure);

Nope, assuming you malloc'ed closure->cif->arg_types and closure->cif. :)

Note that you would also need to free any FFI_TYPE_STRUCT ffi_types that you created.

Dan


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]