MCPcopy Create free account
hub / github.com/MyGUI/mygui / append

Function append

Tools/EditorFramework/pugixml.cpp:6583–6620  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6581 }
6582
6583 void append(const xpath_string& o, xpath_allocator* alloc)
6584 {
6585 // skip empty sources
6586 if (!*o._buffer)
6587 return;
6588
6589 // fast append for constant empty target and constant source
6590 if (!*_buffer && !_uses_heap && !o._uses_heap)
6591 {
6592 _buffer = o._buffer;
6593 }
6594 else
6595 {
6596 // need to make heap copy
6597 size_t target_length = strlength(_buffer);
6598 size_t source_length = strlength(o._buffer);
6599 size_t result_length = target_length + source_length;
6600
6601 // allocate new buffer
6602 char_t* result = static_cast<char_t*>(alloc->reallocate(
6603 _uses_heap ? const_cast<char_t*>(_buffer) : 0,
6604 (target_length + 1) * sizeof(char_t),
6605 (result_length + 1) * sizeof(char_t)));
6606 assert(result);
6607
6608 // append first string to the new buffer in case there was no reallocation
6609 if (!_uses_heap)
6610 memcpy(result, _buffer, target_length * sizeof(char_t));
6611
6612 // append second string to the new buffer
6613 memcpy(result + target_length, o._buffer, source_length * sizeof(char_t));
6614 result[result_length] = 0;
6615
6616 // finalize
6617 _buffer = result;
6618 _uses_heap = true;
6619 }
6620 }
6621
6622 const char_t* c_str() const
6623 {

Callers

nothing calls this directly

Calls 2

strlengthFunction · 0.70
reallocateMethod · 0.45

Tested by

no test coverage detected