summaryrefslogtreecommitdiffhomepage
path: root/Private/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Private/Source')
-rw-r--r--Private/Source/String.cxx9
-rw-r--r--Private/Source/ThreadLocalStorage.cxx4
-rw-r--r--Private/Source/Utils.cxx17
3 files changed, 17 insertions, 13 deletions
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<StringView> StringBuilder::Construct(const Char *data) {
StringView view(rt_string_len(data));
- rt_copy_memory(reinterpret_cast<voidPtr>(const_cast<Char *>(data)),
- reinterpret_cast<voidPtr>(view.Data()), view.Length());
+ view += data;
return ErrorOr<StringView>(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<char *>(rhs), this->m_Cur);
this->m_Cur += rt_string_len(rhs);
diff --git a/Private/Source/ThreadLocalStorage.cxx b/Private/Source/ThreadLocalStorage.cxx
index 30a241ea..ab3b8383 100644
--- a/Private/Source/ThreadLocalStorage.cxx
+++ b/Private/Source/ThreadLocalStorage.cxx
@@ -21,14 +21,14 @@ using namespace HCore;
/**
* Check for cookie inside TIB.
- * @param ptr
+ * @param tib the TIB to check.
* @return if the cookie is enabled.
*/
Boolean tls_check_tib(ThreadInformationBlock* tib) {
if (!tib) return false;
- HCore::Encoder encoder;
+ Encoder encoder;
const char* tibAsBytes = encoder.AsBytes(tib);
kcout << "HCoreKrnl\\TLS: Checking for a valid cookie...\n";
diff --git a/Private/Source/Utils.cxx b/Private/Source/Utils.cxx
index b9264e36..d1b146f8 100644
--- a/Private/Source/Utils.cxx
+++ b/Private/Source/Utils.cxx
@@ -5,6 +5,7 @@
------------------------------------------- */
#include <NewKit/Utils.hpp>
+#include <KernelKit/DebugOutput.hpp>
namespace HCore {
Int rt_string_cmp(const Char *src, const Char *cmp, Size size) {
@@ -36,13 +37,17 @@ Size rt_string_len(const Char *str, SizeT _len) {
return len;
}
-Size rt_string_len(const Char *str) {
- if (*str == '\0') return 0;
+Size rt_string_len(const Char *ptr) {
+ if (!ptr) return 0;
- Size len{0};
- while (str[len] != '\0') ++len;
+ SizeT cnt = 0;
- return len;
+ while (*ptr != (Char)0) {
+ ++ptr;
+ ++cnt;
+ }
+
+ return cnt;
}
voidPtr rt_set_memory(voidPtr src, char value, Size len) {
@@ -70,7 +75,7 @@ Int rt_move_memory(const voidPtr src, voidPtr dst, Size len) {
dstChar[index] = srcChr[index];
srcChr[index] = 0;
- index++;
+ ++index;
}
return 0;