MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / append

Function append

Source/ThirdParty/pugixml/pugixml.cpp:6813–6846  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6811 }
6812
6813 void append(const xpath_string& o, xpath_allocator* alloc)
6814 {
6815 // skip empty sources
6816 if (!*o._buffer) return;
6817
6818 // fast append for constant empty target and constant source
6819 if (!*_buffer && !_uses_heap && !o._uses_heap)
6820 {
6821 _buffer = o._buffer;
6822 }
6823 else
6824 {
6825 // need to make heap copy
6826 size_t target_length = length();
6827 size_t source_length = o.length();
6828 size_t result_length = target_length + source_length;
6829
6830 // allocate new buffer
6831 char_t* result = static_cast<char_t*>(alloc->reallocate(_uses_heap ? const_cast<char_t*>(_buffer) : 0, (target_length + 1) * sizeof(char_t), (result_length + 1) * sizeof(char_t)));
6832 assert(result);
6833
6834 // append first string to the new buffer in case there was no reallocation
6835 if (!_uses_heap) memcpy(result, _buffer, target_length * sizeof(char_t));
6836
6837 // append second string to the new buffer
6838 memcpy(result + target_length, o._buffer, source_length * sizeof(char_t));
6839 result[result_length] = 0;
6840
6841 // finalize
6842 _buffer = result;
6843 _uses_heap = true;
6844 _length_heap = result_length;
6845 }
6846 }
6847
6848 const char_t* c_str() const
6849 {

Callers 5

TInfoSinkBaseClass · 0.85
prefixMethod · 0.85
locationMethod · 0.85
messageMethod · 0.85
appendMethod · 0.85

Calls 4

lengthFunction · 0.85
memcpyFunction · 0.85
reallocateMethod · 0.80
lengthMethod · 0.45

Tested by

no test coverage detected