File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ wrapper! {
29
29
let allocated_len = ( * src) . allocated_len;
30
30
let inner = ffi:: GString {
31
31
str : ffi:: g_malloc( allocated_len) as * mut _,
32
- len: 0 ,
32
+ len: ( * src ) . len ,
33
33
allocated_len,
34
34
} ;
35
35
// +1 to also copy the NUL-terminator
@@ -364,4 +364,17 @@ mod tests {
364
364
write ! ( & mut s, "bla bla {} bla" , 123 ) . unwrap ( ) ;
365
365
assert_eq ! ( & * s, "bla bla 123 bla" ) ;
366
366
}
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
+ }
367
380
}
You can’t perform that action at this time.
0 commit comments