MCPcopy Create free account
hub / github.com/JayXon/Leanify / EnsureCapacity

Method EnsureCapacity

lib/tinyxml2/tinyxml2.h:299–312  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

297 void operator=( const DynArray& ); // not supported
298
299 void EnsureCapacity( int cap ) {
300 TIXMLASSERT( cap > 0 );
301 if ( cap > _allocated ) {
302 TIXMLASSERT( cap <= INT_MAX / 2 );
303 int newAllocated = cap * 2;
304 T* newMem = new T[newAllocated];
305 memcpy( newMem, _mem, sizeof(T)*_size ); // warning: not using constructors, only works for PODs
306 if ( _mem != _pool ) {
307 delete [] _mem;
308 }
309 _mem = newMem;
310 _allocated = newAllocated;
311 }
312 }
313
314 T* _mem;
315 T _pool[INIT];

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected