[][src]Function libffi::low::closure_alloc

pub fn closure_alloc() -> (*mut ffi_closure, CodePtr)

Allocates a closure.

Returns a pair of the writable closure object and the function pointer for calling it. The former acts as a handle to the closure, and is used to configure and free it. The latter is the code pointer used to invoke the closure. Before it can be invoked, it must be initialized with prep_closure and prep_closure_mut. The closure must be deallocated using closure_free, after which point the code pointer should not be used.

Examples

use libffi::low::*;

let (closure_handle, code_ptr) = closure_alloc();