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

Add capacity ctor and SetLength to MemoryStream

This commit is contained in:
disarray2077 2022-11-22 17:30:02 -03:00 committed by GitHub
parent 08d292d3ea
commit 4a0ec6ce8c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -50,6 +50,12 @@ namespace System.IO
mOwns = true;
mMemory = new List<uint8>();
}
public this(int capacity)
{
mOwns = true;
mMemory = new List<uint8>(capacity);
}
public this(List<uint8> memory, bool owns = true)
{
@ -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;
}
}
}