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:
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
||||
it = m_Elements.IsValidIterator( m_LastAlloc ) ? m_Elements.Next( m_LastAlloc ) : m_Elements.First();
|
||||
MEM_ALLOC_CREDIT_CLASS();
|
||||
m_LastAlloc = m_Elements.AddToTail();
|
||||
|
||||
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 ) );
|
||||
}
|
||||
|
Reference in New Issue
Block a user