Exemplo n.º 1
0
 protected DynamicContent(bool binary, int capacity)
 {
     if (binary)
     {
         bytebuf = BufferUtility.GetByteBuffer(capacity);
     }
     else
     {
         charbuf = BufferUtility.GetCharBuffer(capacity);
     }
     count = 0;
 }
Exemplo n.º 2
0
        void AddByte(byte b)
        {
            // ensure capacity
            int olen = bytebuf.Length; // old length

            if (count >= olen)
            {
                int    nlen = olen * 4; // new length
                byte[] obuf = bytebuf;
                bytebuf = BufferUtility.GetByteBuffer(nlen);
                Array.Copy(obuf, 0, bytebuf, 0, olen);
                BufferUtility.Return(obuf);
            }
            bytebuf[count++] = b;

            // calculate checksum
            ulong cs = checksum;

            cs      ^= b;                  // XOR
            checksum = cs >> 57 | cs << 7; // circular left shift 7 bit
        }