1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-22 17:48:01 +02:00

Merge pull request #1759 from disarray2077/patch-7

Add capacity ctor and `SetLength` to MemoryStream
This commit is contained in:
Brian Fiete 2022-11-23 06:00:05 -08:00 committed by GitHub
commit f055c9ff01
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -51,6 +51,12 @@ namespace System.IO
mMemory = new List<uint8>();
}
public this(int capacity)
{
mOwns = true;
mMemory = new List<uint8>(capacity);
}
public this(List<uint8> memory, bool owns = true)
{
mOwns = owns;
@ -90,5 +96,17 @@ namespace System.IO
{
return .Ok;
}
public override Result<void> SetLength(int64 length)
{
Debug.Assert(mOwns);
mMemory.Resize((.)length);
if (Position >= length)
Position = Length;
return .Ok;
}
}
}