MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / allocate

Method allocate

lib/pugixml/src/pugixml.cpp:7627–7662  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7625 }
7626
7627 void* allocate(size_t size)
7628 {
7629 // round size up to block alignment boundary
7630 size = (size + xpath_memory_block_alignment - 1) & ~(xpath_memory_block_alignment - 1);
7631
7632 if (_root_size + size <= _root->capacity)
7633 {
7634 void* buf = &_root->data[0] + _root_size;
7635 _root_size += size;
7636 return buf;
7637 }
7638 else
7639 {
7640 // make sure we have at least 1/4th of the page free after allocation to satisfy subsequent allocation requests
7641 size_t block_capacity_base = sizeof(_root->data);
7642 size_t block_capacity_req = size + block_capacity_base / 4;
7643 size_t block_capacity = (block_capacity_base > block_capacity_req) ? block_capacity_base : block_capacity_req;
7644
7645 size_t block_size = block_capacity + offsetof(xpath_memory_block, data);
7646
7647 xpath_memory_block* block = static_cast<xpath_memory_block*>(xml_memory::allocate(block_size));
7648 if (!block)
7649 {
7650 if (_error) *_error = true;
7651 return 0;
7652 }
7653
7654 block->next = _root;
7655 block->capacity = block_capacity;
7656
7657 _root = block;
7658 _root_size = size;
7659
7660 return block->data;
7661 }
7662 }
7663
7664 void* reallocate(void* ptr, size_t old_size, size_t new_size)
7665 {

Callers 7

duplicate_stringFunction · 0.45
translate_table_generateFunction · 0.45
remove_duplicatesMethod · 0.45
eval_string_concatMethod · 0.45
alloc_nodeMethod · 0.45
alloc_stringMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected