Skip to content
Myr

Shrink unsafe block

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by cactter · committed by David Peter · parent d459c75 · Browse files · 1 file+14 added−12 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+14 added−12 removed

  • other:+14 added−12 removed

1 file+14 added−12 removed

modified:src/timer/windows_timer.rs+14 added-12 removed
32 unmodified lines
33}3435/// Read CPU execution times36fn get_cpu_times(handle: RawHandle) -> CPUTimes {37 let (user_usec, system_usec) = unsafe {38 let mut _ctime = mem::zeroed();39 let mut _etime = mem::zeroed();40 let mut kernel_time = mem::zeroed();41 let mut user_time = mem::zeroed();42 let res = GetProcessTimes(43 handle as HANDLE,44 &mut _ctime,45 &mut _etime,46 &mut kernel_time,47 &mut user_time,48 );37 let (user_usec, system_usec) = {38 let mut _ctime = unsafe { mem::zeroed() };39 let mut _etime = unsafe { mem::zeroed() };40 let mut kernel_time = unsafe { mem::zeroed() };41 let mut user_time = unsafe { mem::zeroed() };42 let res = unsafe {43 GetProcessTimes(44 handle as HANDLE,45 &mut _ctime,46 &mut _etime,47 &mut kernel_time,48 &mut user_time,49 )50 };5152 // GetProcessTimes will exit with non-zero if success as per: https://msdn.microsoft.com/en-us/library/windows/desktop/ms683223(v=vs.85).aspx53 if res != 0 {54 // Extract times as laid out here: https://support.microsoft.com/en-us/help/188768/info-working-with-the-filetime-structure
18 unmodified lines