From 2adc3c61a218f28fe5d817f7cc7ae05e1a927931 Mon Sep 17 00:00:00 2001 From: Ben Wiederhake Date: Sun, 23 Aug 2020 12:56:46 +0200 Subject: [PATCH] AK: Document that String{,Impl} contains NUL-terminator --- AK/String.h | 1 + AK/StringImpl.h | 1 + 2 files changed, 2 insertions(+) diff --git a/AK/String.h b/AK/String.h index 061d697b09d..52c006e0be9 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 47ae2c69059..e85798a06c2 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() }; }