Skip to content

Commit 5276976

Browse files
committed
glib: Use plain g_malloc() instead of g_malloc0() if we initialize the result anyway
1 parent 771461e commit 5276976

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

glib/src/boxed_inline.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ macro_rules! glib_boxed_inline_wrapper {
3030

3131
$crate::glib_boxed_inline_wrapper!(
3232
@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 },
3434
@free ptr unsafe { $crate::ffi::g_free(ptr as *mut _); },
3535
@init _ptr (), @copy_into dest src std::ptr::copy_nonoverlapping(src, dest, 1), @clear _ptr ()
3636
);
@@ -100,7 +100,7 @@ macro_rules! glib_boxed_inline_wrapper {
100100

101101
$crate::glib_boxed_inline_wrapper!(
102102
@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 },
104104
@free ptr unsafe { let c = |$clear_arg| $clear_expr; c(ptr); $crate::ffi::g_free(ptr as *mut _); },
105105
@init $init_arg $init_expr, @copy_into $copy_into_arg_dest $copy_into_arg_src $copy_into_expr, @clear $clear_arg $clear_expr
106106
);

0 commit comments

Comments
 (0)