Commit 41c103b7 authored by Mark OLESEN's avatar Mark OLESEN
Browse files

STYLE: return const char* in CStringList::data()

- and other code style adjustments
parent 5148e4f8
......@@ -128,7 +128,7 @@ public:
inline size_t length() const;
//- The flattened character content, with interspersed nul-chars
inline char* data() const;
inline const char* data() const;
// Edit
......
......@@ -97,7 +97,7 @@ inline char** Foam::CStringList::strings() const
}
inline char* Foam::CStringList::data() const
inline const char* Foam::CStringList::data() const
{
return data_;
}
......
......@@ -31,10 +31,7 @@ Foam::CStringList::CStringList
const UList<StringType>& input
)
:
argc_(0),
len_(0),
argv_(nullptr),
data_(nullptr)
CStringList()
{
reset(input);
}
......@@ -63,12 +60,10 @@ void Foam::CStringList::reset
{
len_ += str.size() + 1;
}
--len_; // No final nul in overall count
argv_ = new char*[input.size()+1];
data_ = new char[len_];
--len_; // Do not include final nul terminator in overall count
argv_[argc_] = nullptr; // extra terminator
argv_ = new char*[input.size()+1]; // Extra +1 for terminating nullptr
data_ = new char[len_+1]; // Extra +1 for terminating nul char
// Copy contents
char* ptr = data_;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment