Ejemplo n.º 1
0
        public IByteArray Alloc(int size)
        {
            ByteArray bytes = null;

            for (int i = 0; i < this.blocks.Count; ++i)
            {
                bytes = this.blocks[i].Capture(size);
                if (null != bytes)
                {
                    return(bytes);
                }
            }

            Logger <IByteStorage> .L("Alloc a new block because there is no enough space for size [" + size + "].");

            var block = new ByteBlock(this, Math.Max(GetProperSize(size), MIN_BUFFER_SIZE));

            this.blocks.Add(block);

            return(block.Capture(size));
        }