1
0
mirror of https://github.com/alliedmodders/hl2sdk.git synced 2025-09-19 20:16:10 +08:00

Correct CUtlLeanVector usages in CUtlRbTree & CUtlLinkedList

This commit is contained in:
GAMMACASE
2025-08-03 02:22:38 +03:00
parent 1008b6f992
commit b7e4cc84ad
2 changed files with 4 additions and 33 deletions

View File

@ -422,29 +422,12 @@ I CUtlLinkedList<T,S,ML,I,M>::AllocInternal( bool multilist )
{
Assert( m_Memory.IsValidIterator( m_LastAlloc ) || m_ElementCount == 0 );
m_Memory.AddToTailGetPtr();
typename M::Iterator_t it = m_Memory.IsValidIterator( m_LastAlloc ) ? m_Memory.Next( m_LastAlloc ) : m_Memory.First();
if ( !m_Memory.IsValidIterator( it ) )
{
MEM_ALLOC_CREDIT_CLASS();
m_Memory.AddToTailGetPtr();
it = m_Memory.IsValidIterator( m_LastAlloc ) ? m_Memory.Next( m_LastAlloc ) : m_Memory.First();
Assert( m_Memory.IsValidIterator( it ) );
if ( !m_Memory.IsValidIterator( it ) )
{
ExecuteNTimes( 10, Warning( "CUtlLinkedList overflow! (exhausted memory allocator)\n" ) );
return InvalidIndex();
}
}
typename M::Iterator_t it = m_Memory.AddToTail();
// We can overflow before the utlmemory overflows, since S != I
if ( !IndexInRange( m_Memory.GetIndex( it ) ) )
{
ExecuteNTimes( 10, Warning( "CUtlLinkedList overflow! (exhausted index range)\n" ) );
Plat_FatalError( "CUtlLinkedList overflow! (exhausted index range)\n" );
return InvalidIndex();
}

View File

@ -709,22 +709,10 @@ I CUtlRBTree<T, I, L, M>::NewNode( bool bConstructElement )
if ( m_FirstFree == InvalidIndex() )
{
Assert( m_Elements.IsValidIterator( m_LastAlloc ) || m_NumElements == 0 );
typename M::Iterator_t it = m_Elements.IsValidIterator( m_LastAlloc ) ? m_Elements.Next( m_LastAlloc ) : m_Elements.First();
if ( !m_Elements.IsValidIterator( it ) )
{
MEM_ALLOC_CREDIT_CLASS();
m_Elements.AddToTailGetPtr();
m_LastAlloc = m_Elements.AddToTail();
it = m_Elements.IsValidIterator( m_LastAlloc ) ? m_Elements.Next( m_LastAlloc ) : m_Elements.First();
Assert( m_Elements.IsValidIterator( it ) );
if ( !m_Elements.IsValidIterator( it ) )
{
Plat_FatalErrorFunc( "CUtlRBTree overflow with %u elements!\n", Count() );
DebuggerBreak();
}
}
m_LastAlloc = it;
elem = m_Elements.GetIndex( m_LastAlloc );
Assert( m_Elements.IsValidIterator( m_LastAlloc ) );
}