diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-07-13 00:20:21 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-07-13 00:20:21 +0200 |
| commit | bc7870aea4c437e1a80b779eb7a968d55733d24c (patch) | |
| tree | 7998fe2f1ef8d3bdf8d37a0b2b2600143bc285ed /Kernel/Sources/String.cxx | |
| parent | 710ce66beaba3bee7289047406ef794c258143e6 (diff) | |
[IMP] Kernel properties (such as \KernelVersion)
[REFACTOR] Rename KernelHeap to just Heap.
[FIX] Scheduler's way of checking boundaries was not correct.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Kernel/Sources/String.cxx')
| -rw-r--r-- | Kernel/Sources/String.cxx | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/Kernel/Sources/String.cxx b/Kernel/Sources/String.cxx index 2b58d551..2ed52029 100644 --- a/Kernel/Sources/String.cxx +++ b/Kernel/Sources/String.cxx @@ -22,7 +22,7 @@ namespace Kernel Size StringView::Length() const { - return rt_string_len(fData); + return fSz; } bool StringView::operator==(const StringView& rhs) const @@ -214,22 +214,25 @@ namespace Kernel return ret; } - static void string_append(char* lhs, char* rhs, int cur) + STATIC void rt_string_append(Char* lhs, Char* rhs, Int cur) { - if (lhs && rhs) - { - SizeT sz_rhs = rt_string_len(rhs); - - if (sz_rhs == 0) - return; + SizeT sz_rhs = rt_string_len(rhs); + SizeT rhs_i = 0; - rt_copy_memory(rhs, lhs + cur, sz_rhs); + for (; rhs_i < sz_rhs; ++rhs_i) + { + lhs[rhs_i + cur] = rhs[rhs_i]; } + + lhs[rhs_i + cur] = 0; } StringView& StringView::operator+=(const Char* rhs) { - string_append(this->fData, const_cast<char*>(rhs), this->fCur); + if (rt_string_len(rhs) > this->Length()) + return *this; + + rt_string_append(this->fData, const_cast<Char*>(rhs), this->fCur); this->fCur += rt_string_len(rhs); return *this; @@ -237,11 +240,11 @@ namespace Kernel StringView& StringView::operator+=(const StringView& rhs) { - if (rt_string_len(rhs.fData) > rt_string_len(this->fData)) + if (rt_string_len(rhs.fData) > this->Length()) return *this; - string_append(this->fData, const_cast<char*>(rhs.fData), this->fCur); - this->fCur += rt_string_len(const_cast<char*>(rhs.fData)); + rt_string_append(this->fData, const_cast<Char*>(rhs.fData), this->fCur); + this->fCur += rt_string_len(const_cast<Char*>(rhs.fData)); return *this; } |
