GetSlotTableLength() private method

private GetSlotTableLength ( ) : int
return int
        [System.Security.SecuritySafeCritical]  // auto-generated
        private LocalDataStoreElement PopulateElement(LocalDataStoreSlot slot)
        {
            bool tookLock = false;

            RuntimeHelpers.PrepareConstrainedRegions();
            try {
                Monitor.Enter(m_Manager, ref tookLock);

                // Make sure that the slot was not freed in the meantime
                int slotIdx = slot.Slot;
                if (slotIdx < 0)
                {
                    throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_SlotHasBeenFreed"));
                }

                if (slotIdx >= m_DataTable.Length)
                {
                    int capacity = m_Manager.GetSlotTableLength();

                    // Validate that the specified capacity is larger than the current one.
                    Contract.Assert(capacity >= m_DataTable.Length, "LocalDataStore corrupted: capacity >= m_DataTable.Length");

                    // Allocate the new data table.
                    LocalDataStoreElement[] NewDataTable = new LocalDataStoreElement[capacity];

                    // Copy all the objects into the new table.
                    Array.Copy(m_DataTable, NewDataTable, m_DataTable.Length);

                    // Save the new table.
                    m_DataTable = NewDataTable;
                }

                // Validate that there is enough space in the local data store now
                Contract.Assert(slotIdx < m_DataTable.Length, "LocalDataStore corrupted: slotIdx < m_DataTable.Length");

                if (m_DataTable[slotIdx] == null)
                {
                    m_DataTable[slotIdx] = new LocalDataStoreElement(slot.Cookie);
                }

                return(m_DataTable[slotIdx]);
            }
            finally {
                if (tookLock)
                {
                    Monitor.Exit(m_Manager);
                }
            }
        }
        /*=========================================================================
        ** This method does the actual work of setting the data.
        ** =========================================================================*/
        internal void SetDataInternal(int slot, Object data, bool bAlloc)
        {
            // We try to delay allocate the dataTable (in cases like the manager clearing a
            // just-freed slot in all stores
            if (slot >= m_DataTable.Length)
            {
                if (!bAlloc)
                {
                    return;
                }
                SetCapacity(m_Manager.GetSlotTableLength());
            }

            // Set the data on the given slot.
            m_DataTable[slot] = data;
        }