This is the mail archive of the
libffi-discuss@sourceware.org
mailing list for the libffi project.
User data with closures?
- From: The Devils Jester <thedevilsjester at gmail dot com>
- To: libffi-discuss at sourceware dot org
- Date: Thu, 28 Feb 2013 22:34:09 -0600
- Subject: User data with closures?
The ffi_prep_closure_loc function allows you to specify a pointer to
user data which becomes part of the closure function. I use this as
an identification so that multiple objects can call the same closure
and I can react to them in the closure function.
My question is, is there a 'normal' way to set this data after the
ffi_prep_closure_loc function has been called?
If not, would it be safe to create a "container" struct which holds my
id, pass a pointer to a variable of that structs type, and change the
value in the pointed to struct later? (and would that achieve this
goal?)
Baring either of those, do additional calls to ffi_prep_closure_loc
completely recreate the closure? What I mean is typically I call that
function once, and then call the actual "created" function whenever I
need to, but if I were to call ffi_prep_closure_loc every time before
I call the "created" function, would that be a trivial call, or is it
recreating the closure function with each call?