Skip to content
This repository has been archived by the owner on Jun 8, 2021. It is now read-only.

Zeroed #505

Merged
merged 2 commits into from
Jul 15, 2019
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions src/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,10 +366,10 @@ impl<T: 'static, MM: BoxedMemoryManager<T>> Uninitialized for Boxed<T, MM> {
unsafe fn uninitialized() -> Self {
Boxed {
inner: {
let mut inner = Box::<T>::new(mem::zeroed());
MM::init(&mut *inner);
let mut inner = mem::MaybeUninit::zeroed();
MM::init(inner.as_mut_ptr());

AnyBox::Native(inner)
AnyBox::Native(Box::new(inner.assume_init()))
GuillaumeGomez marked this conversation as resolved.
Show resolved Hide resolved
},
_dummy: PhantomData,
}
Expand Down
10 changes: 6 additions & 4 deletions src/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1269,8 +1269,9 @@ impl<T: ObjectType> ObjectExt for T {
return Err(glib_bool_error!("Signal not found"));
}

let mut details = mem::zeroed();
gobject_sys::g_signal_query(signal_id, &mut details);
let mut details = mem::MaybeUninit::zeroed();
gobject_sys::g_signal_query(signal_id, details.as_mut_ptr());
let details = details.assume_init();
if details.signal_id != signal_id {
return Err(glib_bool_error!("Signal not found"));
}
Expand Down Expand Up @@ -1370,8 +1371,9 @@ impl<T: ObjectType> ObjectExt for T {
return Err(glib_bool_error!("Signal not found"));
}

let mut details = mem::zeroed();
gobject_sys::g_signal_query(signal_id, &mut details);
let mut details = mem::MaybeUninit::zeroed();
gobject_sys::g_signal_query(signal_id, details.as_mut_ptr());
let details = details.assume_init();
if details.signal_id != signal_id {
return Err(glib_bool_error!("Signal not found"));
}
Expand Down
4 changes: 2 additions & 2 deletions src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ impl Value {
}

#[doc(hidden)]
pub fn into_raw(mut self) -> gobject_sys::GValue {
pub fn into_raw(self) -> gobject_sys::GValue {
unsafe {
let ret = ptr::read(&self.0);
mem::forget(self);
Expand Down Expand Up @@ -273,7 +273,7 @@ impl From<SendValue> for Value {

impl Uninitialized for Value {
unsafe fn uninitialized() -> Value {
Value(mem::zeroed(), PhantomData)
mem::zeroed()
}
}

Expand Down