Using type definition std::os::raw::c_char

This type will be either i8 or u8, depending on the architecture
This commit is contained in:
Fabrice Reix 2021-11-05 09:08:31 +01:00 committed by Fabrice Reix
parent 901939b715
commit 9ccd7d6a15

View File

@ -93,7 +93,7 @@ pub fn eval(doc: libxml::tree::Document, expr: String) -> Result<Value, XpathErr
libxml::bindings::xmlXPathObjectType_XPATH_STRING => { libxml::bindings::xmlXPathObjectType_XPATH_STRING => {
// TO BE CLEANED // TO BE CLEANED
let c_s = unsafe { *result.ptr }.stringval; let c_s = unsafe { *result.ptr }.stringval;
let c_s2 = c_s as *const i8; let c_s2 = c_s as *const std::os::raw::c_char;
let x = unsafe { CStr::from_ptr(c_s2) }; let x = unsafe { CStr::from_ptr(c_s2) };
//let x = unsafe { CStr::from_ptr(u8::from(c_s2)) }; //let x = unsafe { CStr::from_ptr(u8::from(c_s2)) };
let s = x.to_string_lossy().to_string(); let s = x.to_string_lossy().to_string();