On Thu, Feb 05, 2015 at 09:42:08PM +0100, Denys Vlasenko wrote: > struct passwd *getpwent() > { > static char *line; > static struct passwd pw; > size_t size=0; > if (!f) f = fopen("/etc/passwd", "rbe"); > if (!f) return 0; > return __getpwent_a(f, &pw, &line, &size); > } > > I would prefer that even "struct passwd" is malloced...
I don't think it would make much practical difference. It could be changed though. > But more importantly, bbox can't optimize only for musl. > Other libc'es may have static line buffers there. > > And musl will eventually be forced to implement getpwent_r() > if it wants to be usable for more packages... so... getpwent_r makes no sense; the _r functions are for thread-safe versions of their corresponding legacy functions, but getpwent_r has inherent global state -- the iterator. Whoever made it just wasn't thinking. To make a correct interface like this the caller would need to have an iterator object to pass to the function, but I can't see much merit in inventing a new interface for this. Rich _______________________________________________ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox