1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:07:45 +00:00

LibCore+LibIPC: Add Core::AnonymousBuffer, an IPC-friendly buffer class

This will be used to migrate remaining clients off of shbufs.
This commit is contained in:
Andreas Kling 2021-01-16 17:18:58 +01:00
parent a7f63eab84
commit 9c6c18d9b6
6 changed files with 243 additions and 0 deletions

View file

@ -27,6 +27,7 @@
#include <AK/ByteBuffer.h>
#include <AK/String.h>
#include <AK/URL.h>
#include <LibCore/AnonymousBuffer.h>
#include <LibIPC/Dictionary.h>
#include <LibIPC/Encoder.h>
#include <LibIPC/File.h>
@ -170,4 +171,13 @@ Encoder& Encoder::operator<<(const File& file)
return *this;
}
bool encode(Encoder& encoder, const Core::AnonymousBuffer& buffer)
{
encoder << buffer.is_valid();
if (buffer.is_valid()) {
encoder << (u32)buffer.size();
encoder << IPC::File(buffer.fd());
}
return true;
}
}