1 2 3 4 5 6 7 8 9 10 11
use libc; use std::ffi::CString; pub fn stoptr(s: &str) -> *const libc::c_char { let cstr = CString::new(s).unwrap(); cstr.into_raw() as *const i8 } pub fn ptrtos(ptr: *const i8) -> CString { unsafe { CString::from_raw(ptr as *mut i8) } }