diff --git a/libluna/include/luna/String.h b/libluna/include/luna/String.h index 99aa7854..0bdf7395 100644 --- a/libluna/include/luna/String.h +++ b/libluna/include/luna/String.h @@ -91,5 +91,7 @@ class String usize m_length { 0 }; + void empty(); + static Result vformat(StringView fmt, va_list ap); }; diff --git a/libluna/src/String.cpp b/libluna/src/String.cpp index 8d5a6595..1a17bbbe 100644 --- a/libluna/src/String.cpp +++ b/libluna/src/String.cpp @@ -5,6 +5,11 @@ #include String::String() +{ + empty(); +} + +void String::empty() { m_inline = true; m_length = 0; @@ -20,7 +25,7 @@ String::String(String&& other) if (m_inline) memcpy(m_inline_storage, other.m_inline_storage, sizeof(m_inline_storage)); - other.m_string = nullptr; + other.empty(); } String& String::operator=(String&& other) @@ -36,7 +41,7 @@ String& String::operator=(String&& other) if (m_inline) memcpy(m_inline_storage, other.m_inline_storage, sizeof(m_inline_storage)); - other.m_string = nullptr; + other.empty(); return *this; }