Skip to content
Merged
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
15 changes: 14 additions & 1 deletion glib/src/gstring_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ wrapper! {
let allocated_len = (*src).allocated_len;
let inner = ffi::GString {
str: ffi::g_malloc(allocated_len) as *mut _,
len: 0,
len: (*src).len,
allocated_len,
};
// +1 to also copy the NUL-terminator
Expand Down Expand Up @@ -364,4 +364,17 @@ mod tests {
write!(&mut s, "bla bla {} bla", 123).unwrap();
assert_eq!(&*s, "bla bla 123 bla");
}

#[test]
fn ptr() {
use crate::{
ffi,
translate::{FromGlibPtrFull, IntoGlibPtr},
};

let s: crate::GStringBuilder = crate::GStringBuilder::new("This is a string.");
let s: *const ffi::GString = s.into_glib_ptr();
let s = unsafe { crate::GStringBuilder::from_glib_full(s) };
assert_eq!(&*s, "This is a string.");
}
}
Loading