Replace std::mem::uninitialized with MaybeUninit (#1027)
* Replace `std::mem::uninitialized` with `MaybeUninit` * Avoid undefined behavior when using `MaybeUninit` * Restore unused `PointerState` fields as internally public * Zero-initialize some struct values in Xlib FFI calls * Reform usage of `MaybeUninit` in Xlib FFI * Prefer safe zero-initialization using `Default`, when possible * Zero-initialize integers and floats using `0` or `0.0` * Use `MaybeUninit::uninit` for large byte buffers and union types * Use `MaybeUninit::uninit` when the resulting value is ignored
This commit is contained in:
parent
17b8310517
commit
7daf146801
9 changed files with 186 additions and 126 deletions
|
|
@ -43,13 +43,14 @@ impl XConnection {
|
|||
let mut offset = 0;
|
||||
|
||||
let mut done = false;
|
||||
let mut actual_type = 0;
|
||||
let mut actual_format = 0;
|
||||
let mut quantity_returned = 0;
|
||||
let mut bytes_after = 0;
|
||||
let mut buf: *mut c_uchar = ptr::null_mut();
|
||||
|
||||
while !done {
|
||||
unsafe {
|
||||
let mut actual_type: ffi::Atom = mem::uninitialized();
|
||||
let mut actual_format: c_int = mem::uninitialized();
|
||||
let mut quantity_returned: c_ulong = mem::uninitialized();
|
||||
let mut bytes_after: c_ulong = mem::uninitialized();
|
||||
let mut buf: *mut c_uchar = ptr::null_mut();
|
||||
(self.xlib.XGetWindowProperty)(
|
||||
self.display,
|
||||
window,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue