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

Method EnsureCapacity

src/tier1/utlmemory.cpp:278–304  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Makes sure we've got at least this much memory -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

276// Makes sure we've got at least this much memory
277//-----------------------------------------------------------------------------
278void 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//-----------------------------------------------------------------------------

Callers 7

DecodeBase64ToBufMethod · 0.45
LoadFileIntoBufferFunction · 0.45
PrintDHKeyFunction · 0.45
PollRawUDPSocketsFunction · 0.45
TestEllipticPerfFunction · 0.45

Calls

no outgoing calls

Tested by 1

TestEllipticPerfFunction · 0.36