diff options
author | Yuqian Yang <crupest@crupest.life> | 2025-09-08 23:08:10 +0800 |
---|---|---|
committer | Yuqian Yang <crupest@crupest.life> | 2025-09-08 23:08:10 +0800 |
commit | 37d9a034013b4245a50c0d748dc83d2c3d136210 (patch) | |
tree | 3cee1be334acc4d917e9d6b3cbe3e03b653116ac /src/base | |
parent | 0b0c32a1d688389c36f1847edf77af1fd7a2f9d7 (diff) | |
download | cru-37d9a034013b4245a50c0d748dc83d2c3d136210.tar.gz cru-37d9a034013b4245a50c0d748dc83d2c3d136210.tar.bz2 cru-37d9a034013b4245a50c0d748dc83d2c3d136210.zip |
Fix windows dynamic lib build.
Diffstat (limited to 'src/base')
-rw-r--r-- | src/base/String.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/base/String.cpp b/src/base/String.cpp index e9623201..29cebde3 100644 --- a/src/base/String.cpp +++ b/src/base/String.cpp @@ -54,7 +54,13 @@ String String::FromStdPath(const std::filesystem::path& path) { return String::FromUtf8(path.string()); } -char16_t String::kEmptyBuffer[1] = {0}; +namespace { +char16_t kEmptyBuffer[1] = {0}; +} + +String::String() + : buffer_(kEmptyBuffer), + size_(0), capacity_(0) {} String::String(const_pointer str) : String(str, GetStrSize(str)) {} @@ -83,7 +89,11 @@ String::String(const wchar_t* str, Index size) #endif String::String(const String& other) { - if (other.size_ == 0) return; + if (other.size_ == 0) { + this->buffer_ = kEmptyBuffer; + this->size_ = this->capacity_ = 0; + return; + } this->buffer_ = new value_type[other.size_ + 1]; std::memcpy(this->buffer_, other.buffer_, other.size_ * sizeof(value_type)); this->buffer_[other.size_] = 0; |