diff options
author | Gonzalo Paniagua Javier <gonzalo.mono@gmail.com> | 2003-03-05 05:24:44 +0300 |
---|---|---|
committer | Gonzalo Paniagua Javier <gonzalo.mono@gmail.com> | 2003-03-05 05:24:44 +0300 |
commit | b89975d19e5e648e95518b99152866cc0b503b14 (patch) | |
tree | 8fe9ff8a4c7f775849a173377ccc424fa54b7461 /mcs/class/corlib/System.IO/MemoryStream.cs | |
parent | 0cc2a5b351d2efdada00a0eaf6f506fd47ce9f2b (diff) |
2003-03-05 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* MemoryStream.cs: undo my bogus fix in ToArray. Allow GetBuffer and
ToArray even after closing the stream.
svn path=/trunk/mcs/; revision=12204
Diffstat (limited to 'mcs/class/corlib/System.IO/MemoryStream.cs')
-rw-r--r-- | mcs/class/corlib/System.IO/MemoryStream.cs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/mcs/class/corlib/System.IO/MemoryStream.cs b/mcs/class/corlib/System.IO/MemoryStream.cs index 3c45121b048..e9b4ac3dfb4 100644 --- a/mcs/class/corlib/System.IO/MemoryStream.cs +++ b/mcs/class/corlib/System.IO/MemoryStream.cs @@ -193,13 +193,10 @@ namespace System.IO { }
}
- public override void Close() {
- if( streamClosed ) {
- return;
- }
-
+ public override void Close ()
+ {
streamClosed = true;
- internalBuffer = null;
+ expandable = false;
}
public override void Flush() { }
@@ -332,9 +329,9 @@ namespace System.IO { public virtual byte[] ToArray() {
- byte[] outBuffer = new byte[(int)position];
+ byte[] outBuffer = new byte[capacity];
- Buffer.BlockCopyInternal (internalBuffer, 0, outBuffer, 0, (int)position);
+ Buffer.BlockCopyInternal (internalBuffer, 0, outBuffer, 0, capacity);
return outBuffer;
}
@@ -385,6 +382,9 @@ namespace System.IO { public virtual void WriteTo( Stream stream ) {
+ if (streamClosed)
+ throw new ObjectDisposedException ("MemoryStream");
+
if( stream == null ) {
throw new ArgumentNullException();
}
|