| 1051 | } |
| 1052 | |
| 1053 | bool get_mutable_buffer(char_t*& out_buffer, size_t& out_length, const void* contents, size_t size, bool is_mutable) |
| 1054 | { |
| 1055 | if (is_mutable) |
| 1056 | { |
| 1057 | out_buffer = static_cast<char_t*>(const_cast<void*>(contents)); |
| 1058 | } |
| 1059 | else |
| 1060 | { |
| 1061 | void* buffer = global_allocate(size > 0 ? size : 1); |
| 1062 | if (!buffer) return false; |
| 1063 | |
| 1064 | memcpy(buffer, contents, size); |
| 1065 | |
| 1066 | out_buffer = static_cast<char_t*>(buffer); |
| 1067 | } |
| 1068 | |
| 1069 | out_length = size / sizeof(char_t); |
| 1070 | |
| 1071 | return true; |
| 1072 | } |
| 1073 | |
| 1074 | #ifdef PUGIXML_WCHAR_MODE |
| 1075 | inline bool need_endian_swap_utf(xml_encoding le, xml_encoding re) |