----------------------------------------------------------------------------- Makes sure we've got at least this much memory -----------------------------------------------------------------------------
| 276 | // Makes sure we've got at least this much memory |
| 277 | //----------------------------------------------------------------------------- |
| 278 | void CUtlMemoryBase::EnsureCapacity( int num ) |
| 279 | { |
| 280 | if (m_nAllocationCount >= num) |
| 281 | return; |
| 282 | |
| 283 | if ( IsExternallyAllocated() ) |
| 284 | { |
| 285 | // Can't grow a buffer whose memory was externally allocated |
| 286 | Assert(0); |
| 287 | return; |
| 288 | } |
| 289 | |
| 290 | UTLMEMORY_TRACK_FREE(); |
| 291 | |
| 292 | m_nAllocationCount = num; |
| 293 | |
| 294 | UTLMEMORY_TRACK_ALLOC(); |
| 295 | |
| 296 | if (m_pMemory) |
| 297 | { |
| 298 | m_pMemory = PvRealloc( m_pMemory, (size_t)m_nAllocationCount * m_unSizeOfElements ); |
| 299 | } |
| 300 | else |
| 301 | { |
| 302 | m_pMemory = PvAlloc( (size_t)m_nAllocationCount * m_unSizeOfElements ); |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | |
| 307 | //----------------------------------------------------------------------------- |
no outgoing calls