only use for passing to other language
(string: &str)
| 4 | |
| 5 | // only use for passing to other language |
| 6 | pub fn string_to_cstring_ptr(string: &str) -> Result<*const c_char, ()> { |
| 7 | let name_cstr = match CString::new(string) { |
| 8 | Ok(name_cstr) => name_cstr, |
| 9 | Err(err) => { |
| 10 | error!("failed to turn {} into cstring err {:?}", string, err); |
| 11 | return Err(()); |
| 12 | }, |
| 13 | }; |
| 14 | let name_ptr = name_cstr.as_ptr(); |
| 15 | std::mem::forget(name_cstr); |
| 16 | Ok(name_ptr) |
| 17 | } |
no outgoing calls
no test coverage detected