|
|
@ -18,7 +18,7 @@ use std::ffi::CStr; |
|
|
|
|
|
|
|
|
|
|
|
pub fn error_message(ptr: *const c_char) -> String { |
|
|
|
pub fn error_message(ptr: *const c_char) -> String { |
|
|
|
let cstr = unsafe { CStr::from_ptr(ptr as *const _) }; |
|
|
|
let cstr = unsafe { CStr::from_ptr(ptr as *const _) }; |
|
|
|
let s = String::from_utf8_lossy(cstr.to_bytes()).into(); |
|
|
|
let s = String::from_utf8_lossy(cstr.to_bytes()).into_owned(); |
|
|
|
unsafe { |
|
|
|
unsafe { |
|
|
|
libc::free(ptr as *mut c_void); |
|
|
|
libc::free(ptr as *mut c_void); |
|
|
|
} |
|
|
|
} |
|
|
|