From 97b15650f145101c33dbdfd72d41df58ad7ac5b7 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sat, 4 Jul 2020 15:33:59 +0200 Subject: [PATCH] Intialize StringView fields to default values/ --- src/String/BasicStringView.hpp | 4 ++-- src/String/StringView.hpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/String/BasicStringView.hpp b/src/String/BasicStringView.hpp index 0fc1b36..f762ed6 100644 --- a/src/String/BasicStringView.hpp +++ b/src/String/BasicStringView.hpp @@ -5,8 +5,8 @@ namespace ArbUt { class BasicStringView { protected: - size_t _length; - uint32_t _hash; + size_t _length = 0; + uint32_t _hash = 0; constexpr BasicStringView(size_t length, uint32_t hash) : _length(length), _hash(hash) {} diff --git a/src/String/StringView.hpp b/src/String/StringView.hpp index e3a58c5..91facb7 100644 --- a/src/String/StringView.hpp +++ b/src/String/StringView.hpp @@ -17,7 +17,7 @@ namespace ArbUt { class __ConstStringCharHolder { - char* _value; + char* _value = 0; __ConstStringCharHolder(const __ConstStringCharHolder& o) = delete; __ConstStringCharHolder& operator=(const __ConstStringCharHolder& other) = delete; @@ -43,14 +43,14 @@ namespace ArbUt { static std::shared_ptr<__ConstStringCharHolder> __emptyString; static inline const std::shared_ptr<__ConstStringCharHolder>& GetEmptyString() { return __emptyString; } - std::shared_ptr<__ConstStringCharHolder> _str; + std::shared_ptr<__ConstStringCharHolder> _str = GetEmptyString(); public: StringView(const char* str) noexcept : BasicStringView(CalcLength(str), Hash(str)), _str(new __ConstStringCharHolder(str, CalcLength(str))) {} StringView(const char* str, size_t length) noexcept : BasicStringView(length, Hash(str)), _str(new __ConstStringCharHolder(str, length)) {} - StringView() noexcept : BasicStringView(0, Hash("")), _str(GetEmptyString()) {} + StringView() noexcept : BasicStringView(0, Hash("")) {} /* Copy operators */ StringView(const StringView& other) noexcept : BasicStringView(other._length, other._hash), _str(other._str) {}