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

Commit acd49d6

Browse files
Replace mem::uninitialized calls
1 parent ac9a1ea commit acd49d6

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

src/key_file.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,21 +131,21 @@ impl KeyFile {
131131

132132
pub fn get_boolean_list(&self, group_name: &str, key: &str) -> Result<Vec<bool>, Error> {
133133
unsafe {
134-
let mut length = mem::uninitialized();
134+
let mut length = mem::MaybeUninit::uninit();
135135
let mut error = ptr::null_mut();
136136
let ret = glib_sys::g_key_file_get_boolean_list(
137137
self.to_glib_none().0,
138138
group_name.to_glib_none().0,
139139
key.to_glib_none().0,
140-
&mut length,
140+
length.as_mut_ptr(),
141141
&mut error,
142142
);
143143
if !error.is_null() {
144144
return Err(from_glib_full(error));
145145
}
146146
Ok(FromGlibContainer::from_glib_container_num(
147147
ret,
148-
length as usize,
148+
length.assume_init() as usize,
149149
))
150150
}
151151
}

src/main_context.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ use SourceId;
1313
impl MainContext {
1414
pub fn prepare(&self) -> (bool, i32) {
1515
unsafe {
16-
let mut priority = mem::uninitialized();
16+
let mut priority = mem::MaybeUninit::uninit();
1717

1818
let res = from_glib(glib_sys::g_main_context_prepare(
1919
self.to_glib_none().0,
20-
&mut priority,
20+
priority.as_mut_ptr(),
2121
));
22-
22+
let priority = priority.assume_init();
2323
(res, priority)
2424
}
2525
}

src/object.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,7 +1436,7 @@ impl<T: ObjectType> ObjectExt for T {
14361436

14371437
fn downgrade(&self) -> WeakRef<T> {
14381438
unsafe {
1439-
let w = WeakRef(Box::new(mem::uninitialized()), PhantomData);
1439+
let w = WeakRef(Box::new(mem::zeroed()), PhantomData);
14401440
gobject_sys::g_weak_ref_init(
14411441
mut_override(&*w.0),
14421442
self.as_object_ref().to_glib_none().0,
@@ -1530,7 +1530,7 @@ pub struct WeakRef<T: ObjectType>(Box<gobject_sys::GWeakRef>, PhantomData<*const
15301530
impl<T: ObjectType> WeakRef<T> {
15311531
pub fn new() -> WeakRef<T> {
15321532
unsafe {
1533-
let w = WeakRef(Box::new(mem::uninitialized()), PhantomData);
1533+
let w = WeakRef(Box::new(mem::zeroed()), PhantomData);
15341534
gobject_sys::g_weak_ref_init(mut_override(&*w.0), ptr::null_mut());
15351535
w
15361536
}
@@ -1560,7 +1560,7 @@ impl<T: ObjectType> Drop for WeakRef<T> {
15601560
impl<T: ObjectType> Clone for WeakRef<T> {
15611561
fn clone(&self) -> Self {
15621562
unsafe {
1563-
let c = WeakRef(Box::new(mem::uninitialized()), PhantomData);
1563+
let c = WeakRef(Box::new(mem::zeroed()), PhantomData);
15641564

15651565
let o = gobject_sys::g_weak_ref_get(mut_override(&*self.0));
15661566
gobject_sys::g_weak_ref_init(mut_override(&*c.0), o);

src/time_val.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ pub use glib_sys::GTimeVal as TimeVal;
1010

1111
pub fn get_current_time() -> TimeVal {
1212
unsafe {
13-
let mut ret = mem::uninitialized();
14-
glib_sys::g_get_current_time(&mut ret);
15-
ret
13+
let mut ret = mem::MaybeUninit::uninit();
14+
glib_sys::g_get_current_time(ret.as_mut_ptr());
15+
ret.assume_init()
1616
}
1717
}
1818

@@ -27,6 +27,6 @@ impl<'a> ToGlibPtrMut<'a, *mut glib_sys::GTimeVal> for TimeVal {
2727

2828
impl Uninitialized for TimeVal {
2929
unsafe fn uninitialized() -> TimeVal {
30-
mem::uninitialized()
30+
mem::zeroed()
3131
}
3232
}

src/value.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ impl Value {
201201
#[doc(hidden)]
202202
pub fn into_raw(mut self) -> gobject_sys::GValue {
203203
unsafe {
204-
let ret = mem::replace(&mut self.0, mem::uninitialized());
204+
let ret = ptr::read(&self.0);
205205
mem::forget(self);
206206
ret
207207
}

0 commit comments

Comments
 (0)