Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweak Windows implementation #85

Merged
merged 1 commit into from
Aug 30, 2024
Merged

Conversation

RReverser
Copy link
Contributor

  • Fewer deps for Windows (doesn't need libc and memalloc anymore).
  • Somewhat safer allocation - relying on Vec + Drop which is guaranteed to run on any panic / return / etc instead of manually tracking a raw pointer for the buffer.
  • Increase initial buffer size as per official recommendations.
  • Add safe iteration helper for Windows linked lists (assuming that, if the first pointer is valid, then all others should be as well and will have the same lifetime). This significantly reduces number of individual unsafe usages and paves path for Ideally get_interfaces() should return an Iterator #45 as the entire function is now just an iterator + .collect().
  • Simplify socket address conversions by relying on Rust's built-in endianness helpers and the SOCKADDR_INET helper union.

 - Fewer deps for Windows (doesn't need libc and memalloc anymore).
 - Somewhat safer allocation - relying on Vec + Drop which is guaranteed to run on any panic / return / etc instead of manually tracking a raw pointer for the buffer.
 - Increase initial buffer size as per official recommendations.
 - Add safe iteration helper for Windows linked lists (assuming that, if the first pointer is valid, then all others should be as well and will have the same lifetime). This significantly reduces number of individual `unsafe` usages and paves path for shellrow#45 as the entire function is now just an iterator + `.collect()`.
 - Simplify socket address conversions by relying on Rust's built-in endianness helpers and the SOCKADDR_INET helper union.
@shellrow
Copy link
Owner

Tested and confirmed. Thank you for the great improvements!
I've felt the need for safer implementations and refactoring in the Windows implementation, so your changes are very much appreciated.

@shellrow shellrow merged commit 669d891 into shellrow:main Aug 30, 2024
10 checks passed
@RReverser RReverser deleted the windows-tweaks branch August 30, 2024 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants