MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / Alloc

Method Alloc

externals/tinyxml2/tinyxml2.h:371–395  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 2

CreateUnlinkedNodeMethod · 0.80
CreateAttributeMethod · 0.80

Calls 1

PushMethod · 0.80

Tested by

no test coverage detected