rendered paste bodyusing System;
namespace Dazoe
{
class ByteBuffer
{
private byte[] _buf;
private int _length;
public ByteBuffer()
{
_buf = new byte[0];
_length = 0;
}
public void Append(byte[] BytesToAppend)
{
Append(BytesToAppend, BytesToAppend.Length);
}
public void Append(byte[] BytesToAppend, int Length)
{
if (BytesToAppend.Length >= Length)
{
lock (_buf)
{
byte[] tmp = new byte[_buf.Length + Length];
Array.Copy(_buf, tmp, _buf.Length);
Array.Copy(BytesToAppend, 0, tmp, _buf.Length, Length);
_buf = tmp;
}
_length += Length;
}
}
public byte[] Get()
{
byte[] New;
New = Get(_length);
return New;
}
public byte[] Get(int Length)
{
byte[] New = new byte[Length];
byte[] tmp = new byte[_length - Length];
lock (_buf)
{
Array.Copy(_buf, New, Length);
Array.Copy(_buf, Length, tmp, 0, _length - Length);
_length -= Length;
_buf = tmp;
}
return New;
}
}
}