Skip to content

Commit

Permalink
chore(win): bumped windows-sys to v0.59.0 (#142)
Browse files Browse the repository at this point in the history
* bumped windows-sys version to 0.59.0, windows.rs needed changed due to LocalFree method call being moved to windows_sysWin32::foUNDATION, and pointer passed to LocalFree requires *mut c_void now (not sure if the fix I did is correct, but it compiles and the example works)

* ran cargo fmt

---------

Co-authored-by: mid <mid@dev.com>
  • Loading branch information
git-g00d and mid authored Sep 16, 2024
1 parent a9fa903 commit 5e08ccd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ libc = "0.2"
neli = "0.6"

[target.'cfg(windows)'.dependencies.windows-sys]
version = "0.48.0"
version = "0.59.0"
features = [
"Win32_Foundation",
"Win32_Networking_WinSock",
Expand Down
11 changes: 4 additions & 7 deletions src/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::{

use windows_sys::Win32::{
Foundation::{
GetLastError, BOOL, ERROR_ADDRESS_NOT_ASSOCIATED, ERROR_BUFFER_OVERFLOW,
GetLastError, LocalFree, BOOL, ERROR_ADDRESS_NOT_ASSOCIATED, ERROR_BUFFER_OVERFLOW,
ERROR_INSUFFICIENT_BUFFER, ERROR_INVALID_PARAMETER, ERROR_NOT_ENOUGH_MEMORY,

Check warning on line 14 in src/windows.rs

View workflow job for this annotation

GitHub Actions / Builds on windows-latest with x86_64-pc-windows-gnu

unused import: `ERROR_INVALID_PARAMETER`

Check warning on line 14 in src/windows.rs

View workflow job for this annotation

GitHub Actions / Builds on windows-latest with x86_64-pc-windows-msvc

unused import: `ERROR_INVALID_PARAMETER`
ERROR_NOT_SUPPORTED, ERROR_NO_DATA, ERROR_SUCCESS, WIN32_ERROR,
},
Expand All @@ -21,11 +21,8 @@ use windows_sys::Win32::{
Networking::WinSock::{
ADDRESS_FAMILY, AF_INET, AF_INET6, AF_UNSPEC, SOCKADDR_IN, SOCKADDR_IN6, SOCKADDR,
},
System::{
Diagnostics::Debug::{
FormatMessageW, FORMAT_MESSAGE_ALLOCATE_BUFFER, FORMAT_MESSAGE_FROM_SYSTEM,
},
Memory::LocalFree,
System::Diagnostics::Debug::{
FormatMessageW, FORMAT_MESSAGE_ALLOCATE_BUFFER, FORMAT_MESSAGE_FROM_SYSTEM,
},
};

Expand Down Expand Up @@ -260,7 +257,7 @@ fn format_error_code(error_code: WIN32_ERROR) -> String {
let error_message = String::from_utf16_lossy(slice);

unsafe {
LocalFree(wide_ptr as isize);
LocalFree(&mut wide_ptr as *mut _ as *mut _);
}

error_message
Expand Down

0 comments on commit 5e08ccd

Please sign in to comment.