public void Add (byte [] group)
{
//Console.WriteLine ("Adding {0} bytes to {1} (next={2}", group.Length,
// buffer == null ? "null" : buffer.Length.ToString (), next);
if (buffer == null){
buffer = group;
next = group.Length;
return;
}
if (align != 0){
if (align == -1)
next = Align (next, group.Length);
else
next = Align (next, align);
align = 0;
}
if (next + group.Length > buffer.Length){
byte [] nb = new byte [System.Math.Max (next, 16) * 2 + group.Length];
Array.Copy (buffer, nb, buffer.Length);
Array.Copy (group, 0, nb, next, group.Length);
next = next + group.Length;
buffer = nb;
} else {
Array.Copy (group, 0, buffer, next, group.Length);
next += group.Length;
}
}