diff options
author | HampusM <hampus@hampusmat.com> | 2022-03-14 10:24:36 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-03-14 10:24:36 +0100 |
commit | a119e6ca70ffab14f0a70908fa3eeb83b41bb5ab (patch) | |
tree | 51b72774694f5e1aac0bb17fc1a5e528dbad9b44 /src/std/smart_string.cpp | |
parent | 6b5754655f78a7f93b756ff902ce9fd80d9dc4ec (diff) |
refactor: rename std to common
Diffstat (limited to 'src/std/smart_string.cpp')
-rw-r--r-- | src/std/smart_string.cpp | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/src/std/smart_string.cpp b/src/std/smart_string.cpp deleted file mode 100644 index b24a1a5..0000000 --- a/src/std/smart_string.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include "smart_string.hpp" - -#include "std/memory.hpp" - -#include <stdlib.h> - -SmartString::SmartString(char *c_string) : c_str(c_string) -{ -} - -SmartString::SmartString(unsigned int size) : c_str(malloc_s<char>(size + 1)) -{ -} - -SmartString::SmartString(const SmartString &smart_str) - : c_str(malloc_s<char>(strlen(smart_str.c_str) + 1)) -{ - memcpy(c_str, smart_str.c_str, strlen(smart_str.c_str) + 1); -} - -SmartString::SmartString(SmartString &&smart_str) noexcept : c_str(smart_str.c_str) -{ - smart_str.c_str = nullptr; -} - -SmartString &SmartString::operator=(const SmartString &smart_str) -{ - if (&smart_str != this) - { - free(c_str); - c_str = nullptr; - - auto str_size = strlen(smart_str.c_str) + 1; - - c_str = malloc_s<char>(str_size); - memcpy(c_str, smart_str.c_str, str_size); - } - - return *this; -} - -SmartString &SmartString::operator=(SmartString &&smart_str) noexcept -{ - if (&smart_str != this) - { - free(c_str); - c_str = smart_str.c_str; - smart_str.c_str = nullptr; - } - - return *this; -} - -SmartString::~SmartString() -{ - if (c_str != nullptr) - { - free(c_str); - } -} - -SmartString::operator char *() const -{ - return c_str; -} |