From d2046e79cfd915429b4755ef8e1338a1baa7815f Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 16 Nov 2018 17:56:18 +0100 Subject: Add a DoubleBuffer thingy to allow TTY read/write to be interleaved. I feel like this concept might be useful in more places. It's very naive right now and uses dynamically growing buffers. It should really use static size buffers and never kmalloc(). --- AK/Vector.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'AK/Vector.h') diff --git a/AK/Vector.h b/AK/Vector.h index 8824e10a46..d52cea64e2 100644 --- a/AK/Vector.h +++ b/AK/Vector.h @@ -188,6 +188,14 @@ public: ++m_impl->m_size; } + void append(const T* values, size_t count) + { + ensureCapacity(size() + count); + for (size_t i = 0; i < count; ++i) + new (m_impl->slot(m_impl->m_size + i)) T(values[i]); + m_impl->m_size += count; + } + void ensureCapacity(size_t neededCapacity) { if (capacity() >= neededCapacity) -- cgit v1.2.3