aboutsummaryrefslogtreecommitdiff
path: root/backend/String.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'backend/String.cpp')
-rw-r--r--backend/String.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/backend/String.cpp b/backend/String.cpp
index c856d86..e5512bf 100644
--- a/backend/String.cpp
+++ b/backend/String.cpp
@@ -26,8 +26,11 @@ String::String(String && other) {
}
String & String::operator = (String && other) {
if (this == &other) return *this;
+ safe_free(this->_data);
this->_data = other._data;
this->_data_len = other._data_len;
+ other._data = nullptr;
+ other._data_len = 0;
return *this;
}
@@ -90,3 +93,12 @@ bool String::empty() const {
return this->_data_len == 0;
}
+
+bool operator == (const String & a, const String & b) {
+ return strncmp(a._data, b._data, min(a._data_len, b._data_len)) == 0;
+}
+
+bool operator != (const String & a, const String & b) {
+ return !(a == b);
+}
+