aboutsummaryrefslogtreecommitdiff
path: root/sp/src/public/tier1/utlblockmemory.h
diff options
context:
space:
mode:
Diffstat (limited to 'sp/src/public/tier1/utlblockmemory.h')
-rw-r--r--sp/src/public/tier1/utlblockmemory.h15
1 files changed, 8 insertions, 7 deletions
diff --git a/sp/src/public/tier1/utlblockmemory.h b/sp/src/public/tier1/utlblockmemory.h
index 69885060..b4a254ff 100644
--- a/sp/src/public/tier1/utlblockmemory.h
+++ b/sp/src/public/tier1/utlblockmemory.h
@@ -247,15 +247,16 @@ void CUtlBlockMemory<T,I>::ChangeSize( int nBlocks )
UTLBLOCKMEMORY_TRACK_ALLOC(); // this must stay after the recalculation of m_nBlocks, since it implicitly uses the new value
- // free old blocks if shrinking
- for ( int i = m_nBlocks; i < nBlocksOld; ++i )
- {
- UTLBLOCKMEMORY_TRACK_FREE();
- free( (void*)m_pMemory[ i ] );
- }
-
if ( m_pMemory )
{
+ // free old blocks if shrinking
+ // Only possible if m_pMemory is non-NULL (and avoids PVS-Studio warning)
+ for ( int i = m_nBlocks; i < nBlocksOld; ++i )
+ {
+ UTLBLOCKMEMORY_TRACK_FREE();
+ free( (void*)m_pMemory[ i ] );
+ }
+
MEM_ALLOC_CREDIT_CLASS();
m_pMemory = (T**)realloc( m_pMemory, m_nBlocks * sizeof(T*) );
Assert( m_pMemory );