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

Reduce usage of libc #114

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Reduce usage of libc #114

wants to merge 1 commit into from

Conversation

notgull
Copy link

@notgull notgull commented Sep 27, 2024

I am attempting to reduce the dependence on libc in my indirect
dependencies. While looking at this crate I noticed some low-hanging
fruit that can be very easily replaced with libc.

  • The rand() function can be re-implemented as a simple Wyrand seeded by
    the thread ID and the current time.
  • libc::memcpy is used at a point where it can be replaced with
    ptr::copy_nonoverlapping.
  • libc is used for memory allocation at a point where std::alloc can be
    used instead. So I use this.

I'm not too familiar with this codebase, so if any of these replacements
are incorrect, please let me know.

The only leftover libc call is mprotect().

I am attempting to reduce the dependence on libc in my indirect
dependencies. While looking at this crate I noticed some low-hanging
fruit that can be very easily replaced with libc.

- The rand() function can be re-implemented as a simple Wyrand seeded by
  the thread ID and the current time.
- libc::memcpy is used at a point where it can be replaced with
  ptr::copy_nonoverlapping.
- libc is used for memory allocation at a point where std::alloc can be
  used instead. So I use this.

I'm not too familiar with this codebase, so if any of these replacements
are incorrect, please let me know.

The only leftover libc call is mprotect().

Signed-off-by: John Nunley <dev@notgull.net>
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.

1 participant