Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions net/FlatBuffers/ByteBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,22 @@ public T[] ToArray<T>(int pos, int len)
}
#endif

public T[] ToArrayPadded<T>(int pos, int len, int padLeft, int padRight)
where T : struct
{
AssertOffsetAndLength(pos, len);
int totalBytes = padLeft + len + padRight;
byte[] raw = _buffer.Buffer;
T[] arr = new T[totalBytes];
Buffer.BlockCopy(raw, pos, arr, padLeft, len);
return arr;
}

public byte[] ToSizedArrayPadded(int padLeft, int padRight)
{
return ToArrayPadded<byte>(Position, Length - Position, padLeft, padRight);
}

public byte[] ToSizedArray()
{
return ToArray<byte>(Position, Length - Position);
Expand Down
Loading