Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion rust/suseconnect-agama/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
use std::{
ffi::{CString, IntoStringError},
fmt::Display,
os::raw::c_char,
};

use serde_json::{json, Value};

// Safety requirements: inherited from https://doc.rust-lang.org/std/ffi/struct.CStr.html#method.from_ptr
// expects that rust gets control of string pointer
// note: it is different than libzypp bindings where string is still owned by libzypp
pub(crate) unsafe fn string_from_ptr(c_ptr: *mut i8) -> Result<String, IntoStringError> {
pub(crate) unsafe fn string_from_ptr(c_ptr: *mut c_char) -> Result<String, IntoStringError> {
let c_str = CString::from_raw(c_ptr);
c_str.into_string()
}
Expand Down
4 changes: 2 additions & 2 deletions rust/zypp-agama/src/helpers.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::os::raw::c_void;
use std::os::raw::{c_char, c_void};

// Safety requirements: inherited from https://doc.rust-lang.org/std/ffi/struct.CStr.html#method.from_ptr
pub(crate) unsafe fn string_from_ptr(c_ptr: *const i8) -> String {
pub(crate) unsafe fn string_from_ptr(c_ptr: *const c_char) -> String {
String::from_utf8_lossy(std::ffi::CStr::from_ptr(c_ptr).to_bytes()).into_owned()
}

Expand Down
2 changes: 1 addition & 1 deletion rust/zypp-agama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ impl Zypp {
.iter()
.map(|s| CString::new(*s).expect("CString must not contain internal NUL"))
.collect();
let c_ptr_names: Vec<*const i8> =
let c_ptr_names: Vec<*const c_char> =
c_names.iter().map(|c| c.as_c_str().as_ptr()).collect();
let pattern_names = PatternNames {
size: names.len() as u32,
Expand Down
Loading