MCPcopy Create free account
hub / github.com/BehaviorTree/BehaviorTree.CPP / EnsureCapacity

Method EnsureCapacity

3rdparty/tinyxml2/tinyxml2.h:299–313  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected