From dac638648ce795b5eb5a297413ccd1f805f74cc8 Mon Sep 17 00:00:00 2001 From: Chip Locke Date: Fri, 9 Dec 2016 17:24:11 -0800 Subject: [PATCH 1/2] Fix rather embarassing typo in nuspec. --- Microsoft.IO.RecyclableMemoryStream.nuspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Microsoft.IO.RecyclableMemoryStream.nuspec b/Microsoft.IO.RecyclableMemoryStream.nuspec index a2dfd8b5..e3a6787d 100644 --- a/Microsoft.IO.RecyclableMemoryStream.nuspec +++ b/Microsoft.IO.RecyclableMemoryStream.nuspec @@ -2,8 +2,8 @@ Microsoft.IO.RecyclableMemoryStream - 1.2.0 - Micrisift.IO.RecyclableMemoryStream + 1.2.1 + Microsoft.IO.RecyclableMemoryStream Ben Watson; Chip Locke https://github.com/Microsoft/Microsoft.IO.RecyclableMemoryStream/blob/master/LICENSE https://github.com/Microsoft/Microsoft.IO.RecyclableMemoryStream From ef151ba28bfabf12e7a2fe046daf6f7806fad55d Mon Sep 17 00:00:00 2001 From: Chip Locke Date: Fri, 9 Dec 2016 17:24:17 -0800 Subject: [PATCH 2/2] Test+fix for allocating int.MaxValue stream size. --- UnitTests/Tests.cs | 3 +++ src/RecyclableMemoryStream.cs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/UnitTests/Tests.cs b/UnitTests/Tests.cs index b0b2443a..cd56777e 100644 --- a/UnitTests/Tests.cs +++ b/UnitTests/Tests.cs @@ -444,6 +444,9 @@ public void GiantAllocationSucceeds() var stream = mgr.GetStream(null, requestedSize); Assert.IsTrue(stream.Capacity >= requestedSize); } + + var maxStream = mgr.GetStream(null, int.MaxValue); + Assert.IsTrue(maxStream.Capacity == int.MaxValue); } #endregion diff --git a/src/RecyclableMemoryStream.cs b/src/RecyclableMemoryStream.cs index d85d518a..c9b41c48 100644 --- a/src/RecyclableMemoryStream.cs +++ b/src/RecyclableMemoryStream.cs @@ -314,7 +314,7 @@ public override int Capacity return this.largeBuffer.Length; } - long size = this.blocks.Count * this.memoryManager.BlockSize; + long size = (long)this.blocks.Count * this.memoryManager.BlockSize; return (int)Math.Min(int.MaxValue, size); } set