X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fstdio%2Ffread.c;h=aef75f7376f700dd584bf346ab1b7b17717ab097;hb=b6e1fe0d5e78dac647e85d49c2d537bb071ba49e;hp=5c2357776dc71ccf983ee7015f9ff2b02824bf69;hpb=94a0171d807dc94302d6505041fc58879c27f3bd;p=musl diff --git a/src/stdio/fread.c b/src/stdio/fread.c index 5c235777..aef75f73 100644 --- a/src/stdio/fread.c +++ b/src/stdio/fread.c @@ -1,17 +1,18 @@ #include "stdio_impl.h" +#include #define MIN(a,b) ((a)<(b) ? (a) : (b)) -size_t fread(void *destv, size_t size, size_t nmemb, FILE *f) +size_t fread(void *restrict destv, size_t size, size_t nmemb, FILE *restrict f) { unsigned char *dest = destv; size_t len = size*nmemb, l = len, k; - - /* Never touch the file if length is zero.. */ - if (!l) return 0; + if (!size) nmemb = 0; FLOCK(f); + f->mode |= f->mode-1; + if (f->rend - f->rpos > 0) { /* First exhaust the buffer. */ k = MIN(f->rend - f->rpos, l);