|
Message-ID: <20110816135232.GR132@brightrain.aerifal.cx> Date: Tue, 16 Aug 2011 09:52:32 -0400 From: Rich Felker <dalias@...ifal.cx> To: musl@...ts.openwall.com Subject: Re: Anti-bloat side project On Tue, Aug 16, 2011 at 03:16:10PM +0200, Moritz Wilhelmy wrote: > On Tue, Aug 16, 2011 at 09:06:43 -0400, Rich Felker wrote: > > Is it possibly implemented as a shell script? The way the shell "read" > > command works, it's required to perform byte-at-a-time reads like > > this. Otherwise, I'm guessing someone just foolishly turned off > > buffering on the FILE... > > In fact, it really is a C program, and sadly, it seems they really > implement it that way (by greping over the code for about 30 seconds); > > See src/mygetline.c on hg tip[1]: > 41 while(1) { > 42 res = read(fd, &ch, 1); > > Maybe coders need to be educated about how not to write code in order to > avoid (syscall-)bloat? > > [1]: http://mlmmj.org/hg/mlmmj/file/tip/src/mygetline.c As they're using a file descriptor rather than a FILE or their own higher-level buffering structure, the design forces them to either require that the file descriptor be seekable (so they can seek back after reading too much) or read one byte at a time. I'm not sure why someone would use file descriptors rather than stdio or something similar for processing text.. Looks lke just a bad design. There's no immediate fix, however, as the issue is a result of the design. Rich
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.