@@ -30,7 +30,7 @@ macro_rules! glib_boxed_inline_wrapper {
30
30
31
31
$crate:: glib_boxed_inline_wrapper!(
32
32
@generic_impl [ $( $attr) * ] $name $( <$( $generic $( : $bound $( + $bound2) * ) ?) ,+>) ?, $ffi_name,
33
- @copy ptr unsafe { let copy = $crate:: ffi:: g_malloc0 ( std:: mem:: size_of:: <$ffi_name>( ) ) as * mut $ffi_name; std:: ptr:: copy_nonoverlapping( ptr, copy, 1 ) ; copy } ,
33
+ @copy ptr unsafe { let copy = $crate:: ffi:: g_malloc ( std:: mem:: size_of:: <$ffi_name>( ) ) as * mut $ffi_name; std:: ptr:: copy_nonoverlapping( ptr, copy, 1 ) ; copy } ,
34
34
@free ptr unsafe { $crate:: ffi:: g_free( ptr as * mut _) ; } ,
35
35
@init _ptr ( ) , @copy_into dest src std:: ptr:: copy_nonoverlapping( src, dest, 1 ) , @clear _ptr ( )
36
36
) ;
@@ -100,7 +100,7 @@ macro_rules! glib_boxed_inline_wrapper {
100
100
101
101
$crate:: glib_boxed_inline_wrapper!(
102
102
@generic_impl [ $( $attr) * ] $name $( <$( $generic $( : $bound $( + $bound2) * ) ?) ,+>) ?, $ffi_name,
103
- @copy ptr unsafe { let copy = $crate:: ffi:: g_malloc0 ( std:: mem:: size_of:: <$ffi_name>( ) ) as * mut $ffi_name; let c = |$copy_into_arg_dest, $copy_into_arg_src| $copy_into_expr; c( copy, ptr) ; copy } ,
103
+ @copy ptr unsafe { let copy = $crate:: ffi:: g_malloc ( std:: mem:: size_of:: <$ffi_name>( ) ) as * mut $ffi_name; let c = |$copy_into_arg_dest, $copy_into_arg_src| $copy_into_expr; c( copy, ptr) ; copy } ,
104
104
@free ptr unsafe { let c = |$clear_arg| $clear_expr; c( ptr) ; $crate:: ffi:: g_free( ptr as * mut _) ; } ,
105
105
@init $init_arg $init_expr, @copy_into $copy_into_arg_dest $copy_into_arg_src $copy_into_expr, @clear $clear_arg $clear_expr
106
106
) ;
@@ -157,13 +157,30 @@ macro_rules! glib_boxed_inline_wrapper {
157
157
pub fn as_ptr( & self ) -> * mut $ffi_name {
158
158
& self . inner as * const $ffi_name as * mut _
159
159
}
160
+
161
+ #[ doc = "Borrows the underlying C value." ]
162
+ #[ inline]
163
+ pub unsafe fn from_glib_ptr_borrow<' a>( ptr: * const $ffi_name) -> & ' a Self {
164
+ & * ( ptr as * const Self )
165
+ }
166
+
167
+ #[ doc = "Borrows the underlying C value mutably." ]
168
+ #[ inline]
169
+ pub unsafe fn from_glib_ptr_borrow_mut<' a>( ptr: * mut $ffi_name) -> & ' a mut Self {
170
+ & mut * ( ptr as * mut Self )
171
+ }
160
172
}
161
173
162
174
#[ doc( hidden) ]
163
175
impl $( <$( $generic $( : $bound $( + $bound2) * ) ?) ,+>) ? $crate:: translate:: GlibPtrDefault for $name $( <$( $generic) ,+>) ? {
164
176
type GlibType = * mut $ffi_name;
165
177
}
166
178
179
+ #[ doc( hidden) ]
180
+ unsafe impl $( <$( $generic $( : $bound $( + $bound2) * ) ?) ,+>) ? $crate:: translate:: TransparentType for $name $( <$( $generic) ,+>) ? {
181
+ type GlibType = $ffi_name;
182
+ }
183
+
167
184
#[ doc( hidden) ]
168
185
impl $( <$( $generic $( : $bound $( + $bound2) * ) ?) ,+>) ? $crate:: translate:: Uninitialized for $name $( <$( $generic) ,+>) ? {
169
186
#[ inline]
@@ -231,11 +248,12 @@ macro_rules! glib_boxed_inline_wrapper {
231
248
232
249
fn to_glib_container_from_slice( t: & ' a [ Self ] ) -> ( * mut * const $ffi_name, Self :: Storage ) {
233
250
let v_ptr = unsafe {
234
- let v_ptr = $crate:: ffi:: g_malloc0 ( std:: mem:: size_of:: <* const $ffi_name>( ) * ( t. len( ) + 1 ) ) as * mut * const $ffi_name;
251
+ let v_ptr = $crate:: ffi:: g_malloc ( std:: mem:: size_of:: <* const $ffi_name>( ) * ( t. len( ) + 1 ) ) as * mut * const $ffi_name;
235
252
236
253
for ( i, s) in t. iter( ) . enumerate( ) {
237
254
std:: ptr:: write( v_ptr. add( i) , & s. inner as * const $ffi_name) ;
238
255
}
256
+ std:: ptr:: write( v_ptr. add( t. len( ) ) , std:: ptr:: null_mut( ) ) ;
239
257
240
258
v_ptr
241
259
} ;
@@ -245,11 +263,12 @@ macro_rules! glib_boxed_inline_wrapper {
245
263
246
264
fn to_glib_full_from_slice( t: & [ Self ] ) -> * mut * const $ffi_name {
247
265
unsafe {
248
- let v_ptr = $crate:: ffi:: g_malloc0 ( std:: mem:: size_of:: <* const $ffi_name>( ) * ( t. len( ) + 1 ) ) as * mut * const $ffi_name;
266
+ let v_ptr = $crate:: ffi:: g_malloc ( std:: mem:: size_of:: <* const $ffi_name>( ) * ( t. len( ) + 1 ) ) as * mut * const $ffi_name;
249
267
250
268
for ( i, s) in t. iter( ) . enumerate( ) {
251
269
std:: ptr:: write( v_ptr. add( i) , $crate:: translate:: ToGlibPtr :: to_glib_full( s) ) ;
252
270
}
271
+ std:: ptr:: write( v_ptr. add( t. len( ) ) , std:: ptr:: null_mut( ) ) ;
253
272
254
273
v_ptr
255
274
}
@@ -295,7 +314,7 @@ macro_rules! glib_boxed_inline_wrapper {
295
314
296
315
fn to_glib_full_from_slice( t: & [ Self ] ) -> * mut $ffi_name {
297
316
let v_ptr = unsafe {
298
- let v_ptr = $crate:: ffi:: g_malloc0 ( std:: mem:: size_of:: <$ffi_name>( ) ) as * mut $ffi_name;
317
+ let v_ptr = $crate:: ffi:: g_malloc ( std:: mem:: size_of:: <$ffi_name>( ) ) as * mut $ffi_name;
299
318
300
319
for ( i, s) in t. iter( ) . enumerate( ) {
301
320
let copy_into = |$copy_into_arg_dest: * mut $ffi_name, $copy_into_arg_src: * const $ffi_name| $copy_into_expr;
0 commit comments