alef 0.23.15

Opinionated polyglot binding generator for Rust libraries
Documentation
1
2
3
4
5
6
7
8
9
10
/// Free a heap-allocated `{{ enum_name }}` returned by a pointer-returning FFI function.
/// # Safety
/// Pointer must have been returned by this library, or be null.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn {{ prefix }}_{{ enum_snake }}_free(ptr: *mut {{ qualified }}) {
    if !ptr.is_null() {
        // SAFETY: ptr was allocated by Box::into_raw; caller ensures no aliases.
        unsafe { drop(Box::from_raw(ptr)); }
    }
}