summaryrefslogtreecommitdiff
path: root/source/fud_string.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/fud_string.cpp')
-rw-r--r--source/fud_string.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/source/fud_string.cpp b/source/fud_string.cpp
index 52d6b8f..97acb52 100644
--- a/source/fud_string.cpp
+++ b/source/fud_string.cpp
@@ -16,6 +16,7 @@
*/
#include "fud_string.hpp"
+
#include "fud_assert.hpp"
namespace fud {
@@ -115,7 +116,8 @@ String& String::operator=(const String& rhs)
return *this;
}
-String& String::operator=(String&& rhs) {
+String& String::operator=(String&& rhs)
+{
m_length = rhs.m_length;
m_capacity = rhs.m_capacity;
if (rhs.isLarge()) {
@@ -287,7 +289,7 @@ String String::catenate(const String& rhs) const
auto* destPtr = output.data();
auto status = copyMem(destPtr, m_capacity, data(), length());
fudAssert(status == FudStatus::Success);
- status = copyMem(destPtr + length(), m_capacity, rhs.data(), rhs.length());
+ status = copyMem(destPtr + length(), output.m_capacity - length(), rhs.data(), rhs.length());
fudAssert(status == FudStatus::Success);
static_cast<void>(status);
fudAssert(output.nullTerminate() == FudStatus::Success);
@@ -295,7 +297,8 @@ String String::catenate(const String& rhs) const
return output;
}
-bool String::compare(const String& rhs) const {
+bool String::compare(const String& rhs) const
+{
if (!valid() || !rhs.valid()) {
return false;
}
@@ -304,8 +307,7 @@ bool String::compare(const String& rhs) const {
return false;
}
- if (isLarge() && data() == rhs.data())
- {
+ if (isLarge() && data() == rhs.data()) {
return true;
}