librollenspielsache 0.1.2

API for working with tabletop RPG entities.
Documentation
//! This just wraps up strings for passing over the border

use super::*;

/// Helper function to free strings generated by Rust.
/// Clients need to call this to ensure proper cleanup.
/// It is recommended to do iso in a way such that your finding performs this automatically.
/// See the [Rust FFI Omnibus](http://jakegoulding.com/rust-ffi-omnibus/string_return/) for examples.
/// # Safety
/// On a null ptr, returns
#[no_mangle]
pub unsafe extern "C" fn ffi_string_free(s: *mut c_char) {
    {
        if s.is_null() {
            // nothing to do
            return;
        }
        // Otherwise, trigger the Rust destructor when it goes out of scope
        CString::from_raw(s)
    };
}