X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdio%2Ffread.c;h=f1ab3a9adeb84745336a2043e8d0d4c8e95a8882;hb=d9be4032fa26b8714ec95e1da2c0928f9c79dd44;hp=1fdc75326c887ac6bcfc76717e0f20ce38114954;hpb=0ea57627a2a2422a349a0c8c840d09eac084a8ac;p=pdclib.old 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; }