Change strings to use mtl::memmove instead of memcpy ot std::memmove

This commit is contained in:
Myles Busig 2024-03-07 14:32:46 -07:00
parent 7bfc38d978
commit e8601d7807

View File

@ -20,7 +20,7 @@ istring& istring::assign(const istring& str) {
m_size = str.m_size; m_size = str.m_size;
if (m_size > m_capacity) { m_size = m_capacity; } if (m_size > m_capacity) { m_size = m_capacity; }
std::memcpy(m_str, str.m_str, m_size); mtl::memmove(m_str, str.m_str, m_size);
m_str[m_size] = '\0'; m_str[m_size] = '\0';
return *this; return *this;
@ -32,7 +32,7 @@ istring& istring::assign(const istring& str, size_t pos, size_t count) {
if (m_size > m_capacity) { m_size = m_capacity; } if (m_size > m_capacity) { m_size = m_capacity; }
// str may overlap // str may overlap
std::memmove(m_str, str.m_str + pos, m_size); mtl::memmove(m_str, str.m_str + pos, m_size);
m_str[m_size] = '\0'; m_str[m_size] = '\0';
return *this; return *this;
@ -42,7 +42,7 @@ istring& istring::assign(const string_view& str) {
if (m_size > m_capacity) { m_size = m_capacity; } if (m_size > m_capacity) { m_size = m_capacity; }
// str may overlap // str may overlap
mtl::memcpy(m_str, str.c_str(), m_size); mtl::memmove(m_str, str.c_str(), m_size);
m_str[m_size] = '\0'; m_str[m_size] = '\0';
return *this; return *this;
@ -54,7 +54,7 @@ istring& istring::assign(const string_view& str, size_t pos, size_t count) {
if (m_size > m_capacity) { m_size = m_capacity; } if (m_size > m_capacity) { m_size = m_capacity; }
// str may overlap // str may overlap
mtl::memcpy(m_str, str.c_str() + pos, m_size); mtl::memmove(m_str, str.c_str() + pos, m_size);
m_str[m_size] = '\0'; m_str[m_size] = '\0';
return *this; return *this;
@ -205,7 +205,7 @@ istring& istring::insert(size_t index, const istring& str) {
// only copy the string if there is room // only copy the string if there is room
size_t num_to_copy = std::min(str.m_size, space); size_t num_to_copy = std::min(str.m_size, space);
mtl::memcpy(substr, str.m_str, num_to_copy); mtl::memmove(substr, str.m_str, num_to_copy);
m_size += num_to_copy; m_size += num_to_copy;
m_str[m_size] = '\0'; m_str[m_size] = '\0';