- 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;