Skip to content

Commit 869678d

Browse files
elmarcosdroege
authored andcommitted
glib: fix GStringBuilder::copy_into
Signed-off-by: Marc-André Lureau <[email protected]>
1 parent 238347b commit 869678d

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

glib/src/gstring_builder.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ wrapper! {
2929
let allocated_len = (*src).allocated_len;
3030
let inner = ffi::GString {
3131
str: ffi::g_malloc(allocated_len) as *mut _,
32-
len: 0,
32+
len: (*src).len,
3333
allocated_len,
3434
};
3535
// +1 to also copy the NUL-terminator
@@ -364,4 +364,17 @@ mod tests {
364364
write!(&mut s, "bla bla {} bla", 123).unwrap();
365365
assert_eq!(&*s, "bla bla 123 bla");
366366
}
367+
368+
#[test]
369+
fn ptr() {
370+
use crate::{
371+
ffi,
372+
translate::{FromGlibPtrFull, IntoGlibPtr},
373+
};
374+
375+
let s: crate::GStringBuilder = crate::GStringBuilder::new("This is a string.");
376+
let s: *const ffi::GString = s.into_glib_ptr();
377+
let s = unsafe { crate::GStringBuilder::from_glib_full(s) };
378+
assert_eq!(&*s, "This is a string.");
379+
}
367380
}

0 commit comments

Comments
 (0)