[XAM] Fixed size used in read_u16string_and_swap
This commit is contained in:
@@ -429,16 +429,6 @@ inline vec128_t from_string<vec128_t>(const std::string_view value,
|
|||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::u16string read_u16string_and_swap(const char16_t* string_ptr) {
|
|
||||||
std::u16string input_str = std::u16string(string_ptr);
|
|
||||||
|
|
||||||
std::u16string output_str = {};
|
|
||||||
output_str.resize(input_str.size() + 1);
|
|
||||||
copy_and_swap_truncating(output_str.data(), input_str, input_str.size() + 1);
|
|
||||||
output_str.pop_back(); // Remove nullptr added by copy_and_swap.
|
|
||||||
return output_str;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline size_t size_in_bytes(std::variant<std::string, std::u16string> string,
|
inline size_t size_in_bytes(std::variant<std::string, std::u16string> string,
|
||||||
bool include_terminator = true) {
|
bool include_terminator = true) {
|
||||||
if (std::holds_alternative<std::string>(string)) {
|
if (std::holds_alternative<std::string>(string)) {
|
||||||
@@ -452,6 +442,17 @@ inline size_t size_in_bytes(std::variant<std::string, std::u16string> string,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline std::u16string read_u16string_and_swap(const char16_t* string_ptr) {
|
||||||
|
std::u16string input_str = std::u16string(string_ptr);
|
||||||
|
|
||||||
|
std::u16string output_str = {};
|
||||||
|
output_str.resize(input_str.size() + 1);
|
||||||
|
copy_and_swap_truncating(output_str.data(), input_str,
|
||||||
|
size_in_bytes(input_str, false));
|
||||||
|
output_str.pop_back(); // Remove nullptr added by copy_and_swap.
|
||||||
|
return output_str;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace string_util
|
} // namespace string_util
|
||||||
} // namespace xe
|
} // namespace xe
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user