/// <summary>Releases given suballocation, making it free. Merges it with adjacent free suballocations if applicable. Returns iterator to new free suballocation at this place.</summary>
        public D3D12MA_List <D3D12MA_Suballocation> .iterator FreeSuballocation(D3D12MA_List <D3D12MA_Suballocation> .iterator suballocItem)
        {
            // Change this suballocation to be marked as free.
            D3D12MA_Suballocation *suballoc = suballocItem.Get();

            suballoc->type     = D3D12MA_SUBALLOCATION_TYPE_FREE;
            suballoc->userData = null;

            // Update totals.
            ++m_FreeCount;
            m_SumFreeSize += suballoc->size;

            // Merge with previous and/or next suballocation if it's also free.
            bool mergeWithNext = false;
            bool mergeWithPrev = false;

            D3D12MA_List <D3D12MA_Suballocation> .iterator nextItem = suballocItem;
            nextItem = nextItem.MoveNext();

            if ((nextItem != m_Suballocations.end()) && (nextItem.Get()->type == D3D12MA_SUBALLOCATION_TYPE_FREE))
            {
                mergeWithNext = true;
            }

            D3D12MA_List <D3D12MA_Suballocation> .iterator prevItem = suballocItem;

            if (suballocItem != m_Suballocations.begin())
            {
                prevItem = prevItem.MoveBack();

                if (prevItem.Get()->type == D3D12MA_SUBALLOCATION_TYPE_FREE)
                {
                    mergeWithPrev = true;
                }
            }

            if (mergeWithNext)
            {
                UnregisterFreeSuballocation(nextItem);
                MergeFreeWithNext(suballocItem);
            }

            if (mergeWithPrev)
            {
                UnregisterFreeSuballocation(prevItem);
                MergeFreeWithNext(prevItem);
                RegisterFreeSuballocation(prevItem);
                return(prevItem);
            }
            else
            {
                RegisterFreeSuballocation(suballocItem);
                return(suballocItem);
            }
        }
        /// <summary>Given free suballocation, it merges it with following one, which must also be free.</summary>
        public void MergeFreeWithNext(D3D12MA_List <D3D12MA_Suballocation> .iterator item)
        {
            D3D12MA_ASSERT((D3D12MA_DEBUG_LEVEL > 0) && (item != m_Suballocations.end()));
            D3D12MA_ASSERT((D3D12MA_DEBUG_LEVEL > 0) && (item.Get()->type == D3D12MA_SUBALLOCATION_TYPE_FREE));

            D3D12MA_List <D3D12MA_Suballocation> .iterator nextItem = item;
            nextItem = nextItem.MoveNext();

            D3D12MA_ASSERT((D3D12MA_DEBUG_LEVEL > 0) && (nextItem != m_Suballocations.end()));
            D3D12MA_ASSERT((D3D12MA_DEBUG_LEVEL > 0) && (nextItem.Get()->type == D3D12MA_SUBALLOCATION_TYPE_FREE));

            item.Get()->size += nextItem.Get()->size;
            --m_FreeCount;

            m_Suballocations.erase(nextItem);
        }