MCPcopy Create free account
hub / github.com/ajkhoury/ReClassEx / EnsureCapacity

Method EnsureCapacity

ReClass/tinyxml2.h:289–303  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

287 void operator=( const DynArray& ); // not supported
288
289 void EnsureCapacity( int cap ) {
290 TIXMLASSERT( cap > 0 );
291 if ( cap > _allocated ) {
292 TIXMLASSERT( cap <= INT_MAX / 2 );
293 int newAllocated = cap * 2;
294 T* newMem = new T[newAllocated];
295 TIXMLASSERT( newAllocated >= _size );
296 memcpy( newMem, _mem, sizeof(T)*_size ); // warning: not using constructors, only works for PODs
297 if ( _mem != _pool ) {
298 delete [] _mem;
299 }
300 _mem = newMem;
301 _allocated = newAllocated;
302 }
303 }
304
305 T* _mem;
306 T _pool[INITIAL_SIZE];

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected