From a0f82d57976648c5bfcf165b2e304d2a4c8fb0c7 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Tue, 19 Mar 2024 22:50:16 +0100 Subject: Kernel:Secret: Fix String class. Improve kernel APIs. --- Private/Source/String.cxx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'Private/Source/String.cxx') diff --git a/Private/Source/String.cxx b/Private/Source/String.cxx index 23955068..a27a3a37 100644 --- a/Private/Source/String.cxx +++ b/Private/Source/String.cxx @@ -60,8 +60,7 @@ ErrorOr StringBuilder::Construct(const Char *data) { StringView view(rt_string_len(data)); - rt_copy_memory(reinterpret_cast(const_cast(data)), - reinterpret_cast(view.Data()), view.Length()); + view += data; return ErrorOr(view); } @@ -165,16 +164,16 @@ const char *StringBuilder::Format(const char *fmt, const char *fmt2) { } static void string_append(char *lhs, char *rhs, int cur) { - if (lhs && rhs && cur < rt_string_len(lhs)) { + if (lhs && rhs) { SizeT sz_rhs = rt_string_len(rhs); + if (sz_rhs == 0) return; + rt_copy_memory(rhs, lhs + cur, sz_rhs); } } StringView &StringView::operator+=(const Char *rhs) { - if (rt_string_len(rhs) > rt_string_len(this->m_Data)) return *this; - string_append(this->m_Data, const_cast(rhs), this->m_Cur); this->m_Cur += rt_string_len(rhs); -- cgit v1.2.3