Skip to main content

export_free_string

Macro export_free_string 

Source
macro_rules! export_free_string {
    ($(#[$meta:meta])* $free_fn:ident) => { ... };
}
Expand description

Declare the release function for strings this library hands out.

Every entry point returning *mut c_char transfers ownership, so exactly one of these belongs beside them. Reclaiming the allocation has to happen in the library that made it, which is why it cannot be free() on the caller’s side.

unparser_shared::export_free_string!(
    /// Free a string produced by this library.
    ///
    /// # Safety
    ///
    /// - `s` must be a pointer this library returned, or null.
    demo_release_string
);