MCPcopy Create free account
hub / github.com/ValveSoftware/GameNetworkingSockets / Grow

Method Grow

src/tier1/utlmemory.cpp:244–272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

242
243
244void CUtlMemoryBase::Grow( int num )
245{
246 Assert( num > 0 );
247
248 if ( IsExternallyAllocated() )
249 {
250 // Can't grow a buffer whose memory was externally allocated
251 Assert(0);
252 return;
253 }
254
255 // Make sure we have at least numallocated + num allocations.
256 // Use the grow rules specified for this memory (in m_nGrowSize)
257 int nAllocationRequested = m_nAllocationCount + num;
258
259 UTLMEMORY_TRACK_FREE();
260
261 m_nAllocationCount = UtlMemory_CalcNewAllocationCount( m_nAllocationCount, m_nGrowSize, nAllocationRequested, m_unSizeOfElements );
262
263 UTLMEMORY_TRACK_ALLOC();
264 if (m_pMemory)
265 {
266 m_pMemory = PvRealloc( m_pMemory, (size_t)m_nAllocationCount * m_unSizeOfElements );
267 }
268 else
269 {
270 m_pMemory = PvAlloc( (size_t)m_nAllocationCount * m_unSizeOfElements );
271 }
272}
273
274
275//-----------------------------------------------------------------------------

Callers 1

PutOverflowMethod · 0.45

Calls 1

Tested by

no test coverage detected