summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Wiederhake <BenWiederhake.GitHub@gmx.de>2020-08-23 12:56:46 +0200
committerAndreas Kling <kling@serenityos.org>2020-08-24 00:45:03 +0200
commit2adc3c61a218f28fe5d817f7cc7ae05e1a927931 (patch)
tree9968caaa2f890998d9d4a7edea6b5fb5ed052569
parent417ca7594b326eba004ce813625dcc1fd25759c2 (diff)
downloadserenity-2adc3c61a218f28fe5d817f7cc7ae05e1a927931.zip
AK: Document that String{,Impl} contains NUL-terminator
-rw-r--r--AK/String.h1
-rw-r--r--AK/StringImpl.h1
2 files changed, 2 insertions, 0 deletions
diff --git a/AK/String.h b/AK/String.h
index 061d697b09..52c006e0be 100644
--- a/AK/String.h
+++ b/AK/String.h
@@ -142,6 +142,7 @@ public:
bool is_null() const { return !m_impl; }
ALWAYS_INLINE bool is_empty() const { return length() == 0; }
ALWAYS_INLINE size_t length() const { return m_impl ? m_impl->length() : 0; }
+ // Includes NUL-terminator, if non-nullptr.
ALWAYS_INLINE const char* characters() const { return m_impl ? m_impl->characters() : nullptr; }
ALWAYS_INLINE ReadonlyBytes bytes() const { return m_impl ? m_impl->bytes() : nullptr; }
diff --git a/AK/StringImpl.h b/AK/StringImpl.h
index 47ae2c6905..e85798a06c 100644
--- a/AK/StringImpl.h
+++ b/AK/StringImpl.h
@@ -59,6 +59,7 @@ public:
~StringImpl();
size_t length() const { return m_length; }
+ // Includes NUL-terminator.
const char* characters() const { return &m_inline_buffer[0]; }
ALWAYS_INLINE ReadonlyBytes bytes() const { return { characters(), length() }; }