MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / get_mutable_buffer

Function get_mutable_buffer

modules/dasPUGIXML/pugixml/pugixml.cpp:2093–2119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2091 }
2092
2093 PUGI_IMPL_FN bool get_mutable_buffer(char_t*& out_buffer, size_t& out_length, const void* contents, size_t size, bool is_mutable)
2094 {
2095 size_t length = size / sizeof(char_t);
2096
2097 if (is_mutable)
2098 {
2099 out_buffer = static_cast<char_t*>(const_cast<void*>(contents));
2100 out_length = length;
2101 }
2102 else
2103 {
2104 char_t* buffer = static_cast<char_t*>(xml_memory::allocate((length + 1) * sizeof(char_t)));
2105 if (!buffer) return false;
2106
2107 if (contents)
2108 memcpy(buffer, contents, length * sizeof(char_t));
2109 else
2110 assert(length == 0);
2111
2112 buffer[length] = 0;
2113
2114 out_buffer = buffer;
2115 out_length = length + 1;
2116 }
2117
2118 return true;
2119 }
2120
2121#ifdef PUGIXML_WCHAR_MODE
2122 PUGI_IMPL_FN bool need_endian_swap_utf(xml_encoding le, xml_encoding re)

Callers 2

convert_bufferFunction · 0.85
convert_buffer_latin1Function · 0.85

Calls 2

allocateFunction · 0.85
assertFunction · 0.85

Tested by

no test coverage detected