X-Git-Url: https://pd.if.org/git/?p=pdclib;a=blobdiff_plain;f=functions%2Fstdio%2Ffread.c;h=f1ab3a9adeb84745336a2043e8d0d4c8e95a8882;hp=1fdc75326c887ac6bcfc76717e0f20ce38114954;hb=e6d28b5afddd8b3e3564af2264aa8b705e711b67;hpb=7f9e4ed1a81518df0aed2dfe2b18ee12dbadfa79 diff --git a/functions/stdio/fread.c b/functions/stdio/fread.c index 1fdc753..f1ab3a9 100644 --- a/functions/stdio/fread.c +++ b/functions/stdio/fread.c @@ -27,18 +27,10 @@ size_t fread_unlocked( void * _PDCLIB_restrict ptr, size_t nmemb_i; for ( nmemb_i = 0; nmemb_i < nmemb; ++nmemb_i ) { - for ( size_t size_i = 0; size_i < size; ++size_i ) - { - if ( stream->bufidx == stream->bufend ) - { - if ( _PDCLIB_fillbuffer( stream ) == EOF ) - { - /* Could not read requested data */ - return nmemb_i; - } - } - dest[ nmemb_i * size + size_i ] = stream->buffer[ stream->bufidx++ ]; - } + size_t numread = _PDCLIB_getchars( &dest[ nmemb_i * size ], size, EOF, + stream ); + if( numread != size ) + break; } return nmemb_i; }