diff --git a/etk-core/String.cpp b/etk-core/String.cpp index 00fa179..0efe71c 100644 --- a/etk-core/String.cpp +++ b/etk-core/String.cpp @@ -25,7 +25,7 @@ etk::String::String(): //printf("size of string=%ld %ld %ld\n", uint64_t(sizeof(etk::String)), m_sizeLocal, uint64_t(sizeof(etk::Vector))); memset(m_localData, 0, sizeof(m_localData)); #else - //m_data.resize(1, '\0'); + m_data.resize(1, '\0'); #endif } @@ -401,6 +401,7 @@ const etk::String::Iterator etk::String::end() const { void etk::String::resize(size_t _newSize, char _value) { if (_newSize == 0) { m_data.clear(); + m_data.resize(1, '\0'); return; } size_t oldSize = m_data.size(); diff --git a/etk-core/String.hpp b/etk-core/String.hpp index a9e69c5..6f19e48 100644 --- a/etk-core/String.hpp +++ b/etk-core/String.hpp @@ -23,15 +23,13 @@ namespace etk { public: class Iterator { private: - size_t m_current; //!< current Id on the string - String* m_string; //!< Pointer on the current element of the string + size_t m_current = 0; //!< current Id on the string + String* m_string = null; //!< Pointer on the current element of the string public: /** * @brief Basic iterator constructor with no link with an etk::String */ - Iterator(): - m_current(0), - m_string(null) { + Iterator() { // nothing to do ... } /** diff --git a/etk-core/UString.cpp b/etk-core/UString.cpp index 0939d37..c05e756 100644 --- a/etk-core/UString.cpp +++ b/etk-core/UString.cpp @@ -312,14 +312,19 @@ const etk::UString::Iterator etk::UString::begin() const { } etk::UString::Iterator etk::UString::end() { - return position( size()-1 ); + return position( size() ); } const etk::UString::Iterator etk::UString::end() const { - return position( size()-1 ); + return position( size() ); } void etk::UString::resize(size_t _newSize, char32_t _value) { + if (_newSize == 0) { + m_data.clear(); + m_data.resize(1, '\0'); + return; + } size_t oldSize = m_data.size(); if (oldSize != 0) { m_data[m_data.size()-1] = _value; diff --git a/etk-core/UString.hpp b/etk-core/UString.hpp index 8a45218..1988a7e 100644 --- a/etk-core/UString.hpp +++ b/etk-core/UString.hpp @@ -19,15 +19,13 @@ namespace etk { public: class Iterator { private: - size_t m_current; //!< current Id on the string - UString* m_string; //!< Pointer on the current element of the stringBin + size_t m_current = 0; //!< current Id on the string + UString* m_string = null; //!< Pointer on the current element of the stringBin public: /** * @brief Basic iterator constructor with no link with an etk::UString */ - Iterator(): - m_current(0), - m_string(null) { + Iterator() { // nothing to do ... } /**