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:
commit
f055c9ff01
1 changed files with 18 additions and 0 deletions
|
@ -50,6 +50,12 @@ namespace System.IO
|
||||||
mOwns = true;
|
mOwns = true;
|
||||||
mMemory = new List<uint8>();
|
mMemory = new List<uint8>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public this(int capacity)
|
||||||
|
{
|
||||||
|
mOwns = true;
|
||||||
|
mMemory = new List<uint8>(capacity);
|
||||||
|
}
|
||||||
|
|
||||||
public this(List<uint8> memory, bool owns = true)
|
public this(List<uint8> memory, bool owns = true)
|
||||||
{
|
{
|
||||||
|
@ -90,5 +96,17 @@ namespace System.IO
|
||||||
{
|
{
|
||||||
return .Ok;
|
return .Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override Result<void> SetLength(int64 length)
|
||||||
|
{
|
||||||
|
Debug.Assert(mOwns);
|
||||||
|
|
||||||
|
mMemory.Resize((.)length);
|
||||||
|
|
||||||
|
if (Position >= length)
|
||||||
|
Position = Length;
|
||||||
|
|
||||||
|
return .Ok;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue