subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r1569296 - /subversion/trunk/subversion/libsvn_subr/stream.c
Date Tue, 18 Feb 2014 12:40:44 GMT
Author: brane
Date: Tue Feb 18 12:40:44 2014
New Revision: 1569296

URL: http://svn.apache.org/r1569296
Log:
Make the default stream full-read implementation actually work as
advertised. Before this change, it would return the remaining space
in the buffer instead of the number of bytes read.

* subversion/libsvn_subr/stream.c (full_read_fallback): Rewritten from scratch.

Modified:
    subversion/trunk/subversion/libsvn_subr/stream.c

Modified: subversion/trunk/subversion/libsvn_subr/stream.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/stream.c?rev=1569296&r1=1569295&r2=1569296&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/stream.c (original)
+++ subversion/trunk/subversion/libsvn_subr/stream.c Tue Feb 18 12:40:44 2014
@@ -153,30 +153,26 @@ svn_stream__set_is_buffered(svn_stream_t
   stream->is_buffered_fn = is_buffered_fn;
 }
 
-/* Standard implementation for svn_stream_read_full() based on multiple.
-   svn_stream_read2() calls
-   (in separate function to make it more likely for svn_stream_read_full
-    to be inlined) */
+/* Standard implementation for svn_stream_read_full() based on
+   multiple svn_stream_read2() calls (in separate function to make
+   it more likely for svn_stream_read_full to be inlined) */
 static svn_error_t *
 full_read_fallback(svn_stream_t *stream, char *buffer, apr_size_t *len)
 {
-  apr_size_t to_read;
-
-  to_read = *len;
-
-  while (to_read > 0)
+  apr_size_t remaining = *len;
+  while (remaining > 0)
     {
-      *len = to_read;
-      SVN_ERR(svn_stream_read2(stream, buffer, len));
+      apr_size_t length = remaining;
+      SVN_ERR(svn_stream_read2(stream, buffer, &length));
 
-      to_read -= *len;
-      buffer += *len;
-
-      if (*len == 0)
+      if (length == 0)
         {
-          *len = to_read;
+          *len -= remaining;
           return SVN_NO_ERROR;
         }
+
+      remaining -= length;
+      buffer += length;
     }
 
   return SVN_NO_ERROR;



Mime
View raw message