Skip to content

Commit

Permalink
Fix CString::assign(const String&) - must invalidate if source not va…
Browse files Browse the repository at this point in the history
…lid. Add begin() method.
  • Loading branch information
mikee47 committed Nov 26, 2020
1 parent 0935546 commit cfeac1f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Sming/Core/Data/CString.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ class CString : public std::unique_ptr<char[]>

void assign(const String& src)
{
assign(src.c_str(), src.length());
if(src) {
assign(src.c_str(), src.length());
} else {
reset();
}
}

void assign(const char* src)
Expand Down Expand Up @@ -67,6 +71,11 @@ class CString : public std::unique_ptr<char[]>
return *this;
}

char* begin()
{
return get();
}

const char* c_str() const
{
return get() ?: "";
Expand Down

0 comments on commit cfeac1f

Please sign in to comment.