Author: akhaldi
Date: Wed May 14 14:52:00 2014
New Revision: 63292
URL:
http://svn.reactos.org/svn/reactos?rev=63292&view=rev
Log:
[CRT]
* Update fread().
CORE-8080
Modified:
trunk/reactos/lib/sdk/crt/stdio/file.c
Modified: trunk/reactos/lib/sdk/crt/stdio/file.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/stdio/file.c?r…
==============================================================================
--- trunk/reactos/lib/sdk/crt/stdio/file.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/stdio/file.c [iso-8859-1] Wed May 14 14:52:00 2014
@@ -3293,13 +3293,8 @@
while(rcnt>0)
{
int i;
- /* Fill the buffer on small reads.
- * TODO: Use a better buffering strategy.
- */
- if (!file->_cnt && size*nmemb <= BUFSIZ/2 && !(file->_flag
& _IONBF)) {
- if (file->_bufsiz == 0) {
- alloc_buffer(file);
- }
+ if (!file->_cnt && rcnt<BUFSIZ && !(file->_flag &
_IONBF)
+ && (file->_bufsiz != 0 || alloc_buffer(file))) {
file->_cnt = _read(file->_file, file->_base, file->_bufsiz);
file->_ptr = file->_base;
i = ((unsigned int)file->_cnt<rcnt) ? file->_cnt : rcnt;
@@ -3313,8 +3308,12 @@
file->_cnt -= i;
file->_ptr += i;
}
+ } else if (rcnt > UINT_MAX) {
+ i = _read(file->_file, ptr, UINT_MAX);
+ } else if (rcnt < BUFSIZ) {
+ i = _read(file->_file, ptr, rcnt);
} else {
- i = _read(file->_file,ptr, rcnt);
+ i = _read(file->_file, ptr, rcnt - BUFSIZ/2);
}
pread += i;
rcnt -= i;