diff options
author | Ben Wiederhake <BenWiederhake.GitHub@gmx.de> | 2020-08-23 12:56:46 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-08-24 00:45:03 +0200 |
commit | 2adc3c61a218f28fe5d817f7cc7ae05e1a927931 (patch) | |
tree | 9968caaa2f890998d9d4a7edea6b5fb5ed052569 | |
parent | 417ca7594b326eba004ce813625dcc1fd25759c2 (diff) | |
download | serenity-2adc3c61a218f28fe5d817f7cc7ae05e1a927931.zip |
AK: Document that String{,Impl} contains NUL-terminator
-rw-r--r-- | AK/String.h | 1 | ||||
-rw-r--r-- | AK/StringImpl.h | 1 |
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() }; } |