コード例 #1
0
        private void Expand()
        {
            if (this._freePageList._head == -1)
            {
                int length;
                if (this._pages == null)
                {
                    length = 0;
                }
                else
                {
                    length = this._pages.Length;
                }
                int         num2      = length * 2;
                UsagePage[] pageArray = new UsagePage[Math.Min(Math.Max(length + 10, num2), length + 340)];
                for (int j = 0; j < length; j++)
                {
                    pageArray[j] = this._pages[j];
                }
                for (int k = length; k < pageArray.Length; k++)
                {
                    pageArray[k]._pagePrev = k - 1;
                    pageArray[k]._pageNext = k + 1;
                }
                pageArray[length]._pagePrev = -1;
                pageArray[pageArray.Length - 1]._pageNext = -1;
                this._freePageList._head = length;
                this._freePageList._tail = pageArray.Length - 1;
                this._pages = pageArray;
            }
            int pageIndex = this.RemoveFromListHead(ref this._freePageList);

            this.AddToListHead(pageIndex, ref this._freeEntryList);
            UsageEntry[] entryArray = new UsageEntry[0x80];
            entryArray[0]._cFree = 0x7f;
            for (int i = 0; i < (entryArray.Length - 1); i++)
            {
                entryArray[i]._ref1._next = new UsageEntryRef(pageIndex, i + 1);
            }
            entryArray[entryArray.Length - 1]._ref1._next = UsageEntryRef.INVALID;
            this._pages[pageIndex]._entries = entryArray;
            this._cPagesInUse++;
            this.UpdateMinEntries();
        }
コード例 #2
0
 private void Expand()
 {
     if (this._freePageList._head == -1)
     {
         int length;
         if (this._pages == null)
         {
             length = 0;
         }
         else
         {
             length = this._pages.Length;
         }
         int num2 = length * 2;
         UsagePage[] pageArray = new UsagePage[Math.Min(Math.Max(length + 10, num2), length + 340)];
         for (int j = 0; j < length; j++)
         {
             pageArray[j] = this._pages[j];
         }
         for (int k = length; k < pageArray.Length; k++)
         {
             pageArray[k]._pagePrev = k - 1;
             pageArray[k]._pageNext = k + 1;
         }
         pageArray[length]._pagePrev = -1;
         pageArray[pageArray.Length - 1]._pageNext = -1;
         this._freePageList._head = length;
         this._freePageList._tail = pageArray.Length - 1;
         this._pages = pageArray;
     }
     int pageIndex = this.RemoveFromListHead(ref this._freePageList);
     this.AddToListHead(pageIndex, ref this._freeEntryList);
     UsageEntry[] entryArray = new UsageEntry[0x80];
     entryArray[0]._cFree = 0x7f;
     for (int i = 0; i < (entryArray.Length - 1); i++)
     {
         entryArray[i]._ref1._next = new UsageEntryRef(pageIndex, i + 1);
     }
     entryArray[entryArray.Length - 1]._ref1._next = UsageEntryRef.INVALID;
     this._pages[pageIndex]._entries = entryArray;
     this._cPagesInUse++;
     this.UpdateMinEntries();
 }
コード例 #3
0
ファイル: CacheUsage.cs プロジェクト: vhatuncev/corefx
        private void Expand()
        {
            Debug.Assert(_cPagesInUse * NUM_ENTRIES == _cEntriesInUse, "_cPagesInUse * NUM_ENTRIES == _cEntriesInUse");
            Debug.Assert(_freeEntryList._head == -1, "_freeEntryList._head == -1");
            Debug.Assert(_freeEntryList._tail == -1, "_freeEntryList._tail == -1");

            if (_freePageList._head == -1)
            {
                int oldLength;
                if (_pages == null)
                {
                    oldLength = 0;
                }
                else
                {
                    oldLength = _pages.Length;
                }

                Debug.Assert(_cPagesInUse == oldLength, "_cPagesInUse == oldLength");
                Debug.Assert(_cEntriesInUse == oldLength * NUM_ENTRIES, "_cEntriesInUse == oldLength * ExpiresEntryRef.NUM_ENTRIES");

                int newLength = oldLength * 2;
                newLength = Math.Max(oldLength + MIN_PAGES_INCREMENT, newLength);
                newLength = Math.Min(newLength, oldLength + MAX_PAGES_INCREMENT);
                Debug.Assert(newLength > oldLength, "newLength > oldLength");

                UsagePage[] newPages = new UsagePage[newLength];

                for (int i = 0; i < oldLength; i++)
                {
                    newPages[i] = _pages[i];
                }

                for (int i = oldLength; i < newPages.Length; i++)
                {
                    newPages[i]._pagePrev = i - 1;
                    newPages[i]._pageNext = i + 1;
                }

                newPages[oldLength]._pagePrev           = -1;
                newPages[newPages.Length - 1]._pageNext = -1;

                _freePageList._head = oldLength;
                _freePageList._tail = newPages.Length - 1;

                _pages = newPages;
            }

            int pageIndex = RemoveFromListHead(ref _freePageList);

            AddToListHead(pageIndex, ref _freeEntryList);

            UsageEntry[] entries = new UsageEntry[LENGTH_ENTRIES];
            ((entries)[0]._cFree) = NUM_ENTRIES;

            for (int i = 0; i < entries.Length - 1; i++)
            {
                entries[i]._ref1._next = new UsageEntryRef(pageIndex, i + 1);
            }
            entries[entries.Length - 1]._ref1._next = UsageEntryRef.INVALID;

            (_pages[(pageIndex)]._entries) = entries;

            _cPagesInUse++;
            UpdateMinEntries();
        }