Skip to content

Commit

Permalink
Update to use the official maintained windows sys library.
Browse files Browse the repository at this point in the history
Update windows.rs
  • Loading branch information
dtzxporter authored and Arc-blroth committed Jun 26, 2024
1 parent eb1ebf2 commit 02bfe7d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ keywords = ["memory", "performance", "profiling"]
serde = { version = "1.0", optional = true, features = ["derive"] }

[target.'cfg(target_os = "windows")'.dependencies]
windows-sys = { version = "0.52", features = ["Win32_Foundation"] }
windows-sys = { version = "0.52", features = ["Win32_Foundation", "Win32_System", "Win32_System_ProcessStatus", "Win32_System_Threading"] }

[target.'cfg(any(target_os = "linux", target_os = "android", target_os = "macos", target_os = "ios", target_os = "freebsd"))'.dependencies]
libc = "0.2"
Expand Down
8 changes: 2 additions & 6 deletions src/windows.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
use std::mem::MaybeUninit;

use winapi::shared::minwindef::DWORD;
use winapi::um::processthreadsapi::GetCurrentProcess;
use winapi::um::psapi::{GetProcessMemoryInfo, PROCESS_MEMORY_COUNTERS};

use windows_sys::Win32::System::Threading::GetCurrentProcess;
use windows_sys::Win32::System::ProcessStatus::GetProcessMemoryInfo;
use windows_sys::Win32::System::ProcessStatus::PROCESS_MEMORY_COUNTERS;
use windows_sys::Win32::System::Threading::GetCurrentProcess;

use crate::MemoryStats;

Expand All @@ -16,7 +12,7 @@ pub fn memory_stats() -> Option<MemoryStats> {
GetProcessMemoryInfo(
GetCurrentProcess(),
maybe_pmc.as_mut_ptr(),
std::mem::size_of::<PROCESS_MEMORY_COUNTERS>() as DWORD,
std::mem::size_of::<PROCESS_MEMORY_COUNTERS>() as _,
)
} {
// GetProcessMemoryInfo failed
Expand Down

0 comments on commit 02bfe7d

Please sign in to comment.