1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 01:17:34 +00:00

Kernel: Implement peek() function for DoubleBuffer

This allows us to "peek" into a DoubleBuffer without incrementing
the m_read_buffer_index, which is needed to implement MSG_PEEK.
This commit is contained in:
Justin 2021-04-28 23:22:21 +02:00 committed by Andreas Kling
parent 9bcdbe205b
commit 2d098c88dc
2 changed files with 25 additions and 2 deletions

View file

@ -29,6 +29,12 @@ public:
auto buffer = UserOrKernelBuffer::for_kernel_buffer(data);
return read(buffer, size);
}
[[nodiscard]] ssize_t peek(UserOrKernelBuffer&, size_t);
[[nodiscard]] ssize_t peek(u8* data, size_t size)
{
auto buffer = UserOrKernelBuffer::for_kernel_buffer(data);
return peek(buffer, size);
}
bool is_empty() const { return m_empty; }