From 56ea8ad91dbf1660303f3b67b37fda4e6fbe33da Mon Sep 17 00:00:00 2001 From: Madeline Busig Date: Thu, 7 Mar 2024 14:32:46 -0700 Subject: [PATCH] Change strings to use mtl::memmove instead of memcpy ot std::memmove --- src/string.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/string.cpp b/src/string.cpp index 3e6fa5d..6da8ee1 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -20,7 +20,7 @@ istring& istring::assign(const istring& str) { m_size = str.m_size; 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'; 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; } // 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'; return *this; @@ -42,7 +42,7 @@ istring& istring::assign(const string_view& str) { if (m_size > m_capacity) { m_size = m_capacity; } // 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'; 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; } // 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'; return *this; @@ -205,7 +205,7 @@ istring& istring::insert(size_t index, const istring& str) { // only copy the string if there is room 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_str[m_size] = '\0';