libluna: Leave String in a valid state when moved
This commit is contained in:
parent
ae7c841fff
commit
8adfb6fdb9
@ -91,5 +91,7 @@ class String
|
||||
|
||||
usize m_length { 0 };
|
||||
|
||||
void empty();
|
||||
|
||||
static Result<String> vformat(StringView fmt, va_list ap);
|
||||
};
|
||||
|
@ -5,6 +5,11 @@
|
||||
#include <luna/Vector.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user