public BlockAllocator TryGet(int size) { size = AlignToBlock(size); BlockAllocator ba = null; m_bPool.TryGetValue(size, out ba); return(ba); }
public BlockAllocator AddPool(int size, int maxnum, bool extendAble = true) { size = AlignToBlock(size); BlockAllocator ba = null; if (!m_bPool.TryGetValue(size, out ba)) { ba = new BlockAllocator(size, maxnum, extendAble); m_bPool.Add(size, ba); } return(ba); }
public byte[] Allocate(int size) { size = AlignToBlock(size); BlockAllocator allocator = null; if (!m_bPool.TryGetValue(size, out allocator)) { allocator = CreateAllocator(size); m_bPool.Add(size, allocator); } return(allocator.Allocate()); }
public bool Free(ref byte[] p) { if (p != null) { BlockAllocator allocator = null; try { if (m_bPool.TryGetValue(p.Length, out allocator)) { return(allocator.Free(p)); } } finally { p = null; } } return(false); }