MCPcopy Create free account
hub / github.com/Overload-Technologies/Overload / Alloc

Method Alloc

Dependencies/tinyxml2/include/tinyxml2.h:377–401  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

375 }
376
377 virtual void* Alloc() {
378 if ( !_root ) {
379 // Need a new block.
380 Block* block = new Block();
381 _blockPtrs.Push( block );
382
383 Item* blockItems = block->items;
384 for( int i = 0; i < ITEMS_PER_BLOCK - 1; ++i ) {
385 blockItems[i].next = &(blockItems[i + 1]);
386 }
387 blockItems[ITEMS_PER_BLOCK - 1].next = 0;
388 _root = blockItems;
389 }
390 Item* const result = _root;
391 TIXMLASSERT( result != 0 );
392 _root = _root->next;
393
394 ++_currentAllocs;
395 if ( _currentAllocs > _maxAllocs ) {
396 _maxAllocs = _currentAllocs;
397 }
398 ++_nAllocs;
399 ++_nUntracked;
400 return result;
401 }
402
403 virtual void Free( void* mem ) {
404 if ( !mem ) {

Callers 2

CreateAttributeMethod · 0.45
CreateUnlinkedNodeMethod · 0.45

Calls 1

PushMethod · 0.80

Tested by

no test coverage detected