From: Avery Pennarun Date: Fri, 16 May 2008 14:56:35 GMT Subject: Re: [PATCH] mailsplit and mailinfo: gracefully handle NUL characters Message-ID: <32541b130805160756h5a8fc4d7x313f9bfde4760568@mail.gmail.com> In-Reply-To: On 5/16/08, Johannes Schindelin wrote: > Hmpf. I hoped to get more definitive information here. Especially given > that fgetc() is nothing more than a glorified fread() into a buffer, and > then access the buffer. > > Well, at least you kind of pointed me to the _unlocked() function family. Point taken. /tmp $ for d in test1 test2 test3 test3u; do echo -n "$d: "; /usr/bin/time ./$d int main() { char buf[1024]; int i; for (i = 0; i < 102400; i++) fread(buf, 1, sizeof(buf), stdin); } === test2.c === #include int main() { int i; for (i = 0; i < 1024*102400; i++) fgetc(stdin); } === test3.c === #include int main() { int i; for (i = 0; i < 1024*102400; i++) getc(stdin); } === test3u.c === #include int main() { int i; for (i = 0; i < 1024*102400; i++) getc_unlocked(stdin); }