Author: atsushi
Date: 2007-05-23 00:31:06 -0400 (Wed, 23 May 2007)
New Revision: 77823

Modified:
   trunk/mcs/class/corlib/System.IO/ChangeLog
   trunk/mcs/class/corlib/System.IO/UnmanagedMemoryStream.cs
Log:
2007-05-23  Atsushi Enomoto  <[EMAIL PROTECTED]>

        * UnmanagedMemoryStream.cs : couple of bugfixes. in Read(), don't
          return buffer beyond the requested length. Fixed .ctor() for wrong
          capacity initialization.



Modified: trunk/mcs/class/corlib/System.IO/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/System.IO/ChangeLog  2007-05-23 01:20:57 UTC (rev 
77822)
+++ trunk/mcs/class/corlib/System.IO/ChangeLog  2007-05-23 04:31:06 UTC (rev 
77823)
@@ -1,3 +1,9 @@
+2007-05-23  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * UnmanagedMemoryStream.cs : couple of bugfixes. in Read(), don't
+         return buffer beyond the requested length. Fixed .ctor() for wrong
+         capacity initialization.
+
 2007-05-12  Jonathan Chambers  <[EMAIL PROTECTED]>
 
        * FileStream.cs: Implement SafeHandle constructors.

Modified: trunk/mcs/class/corlib/System.IO/UnmanagedMemoryStream.cs
===================================================================
--- trunk/mcs/class/corlib/System.IO/UnmanagedMemoryStream.cs   2007-05-23 
01:20:57 UTC (rev 77822)
+++ trunk/mcs/class/corlib/System.IO/UnmanagedMemoryStream.cs   2007-05-23 
04:31:06 UTC (rev 77823)
@@ -80,7 +80,7 @@
                        initial_pointer = new IntPtr((void*)pointer);
                }
                
-               public unsafe UnmanagedMemoryStream (byte *pointer, long len, 
long cap, FileAccess access)
+               public unsafe UnmanagedMemoryStream (byte *pointer, long len, 
long capacity, FileAccess access)
                {
                        if (pointer == null)
                                throw new ArgumentNullException("The pointer 
value is a null reference");
@@ -92,7 +92,7 @@
                                throw new ArgumentOutOfRangeException("The 
length value is greater than the capacity value");
                        fileaccess = access;
                        length = len;
-                       capacity = cap;
+                       this.capacity = capacity;
                        initial_position = 0;
                        current_position = initial_position;
                        canseek = true;
@@ -108,7 +108,7 @@
                                if (closed)
                                        return false;
                                else
-                                       return ((fileaccess == FileAccess.Read 
|| fileaccess == FileAccess.ReadWrite)? true:false);
+                                       return ((fileaccess == FileAccess.Read 
|| fileaccess == FileAccess.ReadWrite)? current_position < capacity : false);
                        }
                }
 
@@ -189,12 +189,12 @@
                                        if (current_position == capacity)
                                                return (0);
                                        else {
+                                               int progress = current_position 
+ count < capacity ? count : (int) (capacity - current_position);
                                                unsafe {
-                                                       
Marshal.Copy(initial_pointer, buffer, offset, 
-                                                                    
(int)length);
-                                                       current_position += 
length;
+                                                       
Marshal.Copy(initial_pointer, buffer, offset, progress);
+                                                       current_position += 
progress;
                                                }
-                                               return (buffer.GetLength(0));
+                                               return progress;
                                        }
                                }
                        }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to