mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-21 09:27:59 +02:00
Add capacity ctor and SetLength
to MemoryStream
This commit is contained in:
parent
08d292d3ea
commit
4a0ec6ce8c
1 changed files with 18 additions and 0 deletions
|
@ -51,6 +51,12 @@ namespace System.IO
|
||||||
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)
|
||||||
{
|
{
|
||||||
mOwns = owns;
|
mOwns = owns;
|
||||||
|
@ -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