Function tc_string_borrow

Source
#[no_mangle]
pub unsafe extern "C" fn tc_string_borrow(
    cstr: *const c_char,
) -> TCString
Expand description

Create a new TCString referencing the given C string. The C string must remain valid and unchanged until after the TCString is freed. It’s typically easiest to ensure this by using a static string.

NOTE: this function does not take responsibility for freeing the given C string. The given string can be freed once the TCString referencing it has been freed.

For example:

char *url = get_item_url(..); // dynamically allocate C string
tc_task_annotate(task, tc_string_borrow(url)); // TCString created, passed, and freed
free(url); // string is no longer referenced and can be freed
EXTERN_C struct TCString tc_string_borrow(const char *cstr);