mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Kevin Bowling <kevin.bowling@kev009.com>
To: musl@lists.openwall.com
Subject: fgetgrent_a questions/review
Date: Thu, 7 May 2015 05:53:43 -0700	[thread overview]
Message-ID: <CAK7dMtAYxQSe-LeZcZzSo54x0SaU_Pis=CAnR+kHuz-abXQvdg@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 946 bytes --]

Hi,

I borrowed the fget*ent_a functions to port libnss-cache to FreeBSD because
the fgetent family of functions are not standard and the musl
implementations looked clean and compact with a good license.

https://github.com/google/libnss-cache/pull/1/files#diff-800bf143f84497855c6338a07c19b4af

I had to make a few changes which may be suitable for musl.  First, getline
seems to resize the buffer as it pleases but this causes problems since the
glibc implementation uses fgets and generally something higher up the call
stack handles the resizing.  Second, the current musl implementation
doesn't return ERANGE which was necessary to get the caller's (nsswitch)
code to do the right thing to the buffer.

Finally, I wasn't quite sure what to do with mem and nmem in this case.  I
made mem static, and pass nmem in in a wrapper function.. but I do not know
if these are allocated and freed correctly used standalone like this?

Regards,
Kevin

[-- Attachment #2: Type: text/html, Size: 1190 bytes --]

             reply	other threads:[~2015-05-07 12:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-07 12:53 Kevin Bowling [this message]
2015-05-07 16:49 ` Rich Felker
2015-05-17  7:02   ` Kevin Bowling

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAK7dMtAYxQSe-LeZcZzSo54x0SaU_Pis=CAnR+kHuz-abXQvdg@mail.gmail.com' \
    --to=kevin.bowling@kev009.com \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).