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

Decrease initial memory allocation for passwd and grp buffers #20

Closed
wants to merge 3 commits into from

Commits on Jul 1, 2021

  1. Obtain sysconf values just once.

    Instead of querying sysconf once per loop for a value, we should just
    store it during initialization, since it's environment information whose
    value won't change during runtime.
    
    Even so, since most of the time we are on musl, this function always
    returns -1 and we end up using the BUF_LEN_DEFAULT buffer size.
    
    For now, actually using these buffer lengths isn't implemented, because
    the code that uses them is being refactored.
    ericonr committed Jul 1, 2021
    Configuration menu
    Copy the full SHA
    f241e2c View commit details
    Browse the repository at this point in the history
  2. Improve memory usage by decreasing initial buffer size.

    Move BUF_LEN_DEFAULT's value to the one used by glibc in their headers.
    ericonr committed Jul 1, 2021
    Configuration menu
    Copy the full SHA
    c98cd50 View commit details
    Browse the repository at this point in the history

Commits on Jul 4, 2021

  1. Use our own define instead of NGROUPS_MAX.

    musl (as of version 1.2.2) defines NGROUPS_MAX to 32, but glibc and the
    kernel define it to 65536. Since musl might change the definition at
    some point, and the nss_initgroups interface allows the callee to
    realloc the buffer, we don't have to allocate the maximum value upfront,
    and can keep using 32 as a reasonable initial default.
    ericonr committed Jul 4, 2021
    Configuration menu
    Copy the full SHA
    ac312f5 View commit details
    Browse the repository at this point in the history