summaryrefslogtreecommitdiff
path: root/Kernel/KBuffer.h
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-09-08 18:29:52 +0200
committerAndreas Kling <kling@serenityos.org>2021-09-08 20:16:00 +0200
commit524ef5e47596421ddc39d77830c651235f45c15f (patch)
treedb6aa133427b386d5422e74f0be285b8c94421c4 /Kernel/KBuffer.h
parentbee2de4b3109221ed8376d74e811dddf072f8862 (diff)
downloadserenity-524ef5e47596421ddc39d77830c651235f45c15f.zip
Kernel: Add KBuffer::bytes() and use it
(Instead of hand-wrapping { data(), size() } in a bunch of places.)
Diffstat (limited to 'Kernel/KBuffer.h')
-rw-r--r--Kernel/KBuffer.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/Kernel/KBuffer.h b/Kernel/KBuffer.h
index 0b161d3257..2a56410178 100644
--- a/Kernel/KBuffer.h
+++ b/Kernel/KBuffer.h
@@ -42,6 +42,9 @@ public:
[[nodiscard]] size_t size() const { return m_size; }
[[nodiscard]] size_t capacity() const { return m_region->size(); }
+ [[nodiscard]] ReadonlyBytes bytes() const { return { data(), size() }; }
+ [[nodiscard]] Bytes bytes() { return { data(), size() }; }
+
void set_size(size_t size)
{
VERIFY(size <= capacity());