diff options
Diffstat (limited to 'Libraries/LibC/SharedBuffer.cpp')
-rw-r--r-- | Libraries/LibC/SharedBuffer.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/Libraries/LibC/SharedBuffer.cpp b/Libraries/LibC/SharedBuffer.cpp index ef7e31e621..1a0c3a9701 100644 --- a/Libraries/LibC/SharedBuffer.cpp +++ b/Libraries/LibC/SharedBuffer.cpp @@ -3,10 +3,10 @@ #include <stdio.h> #include <unistd.h> -RefPtr<SharedBuffer> SharedBuffer::create(pid_t peer, int size) +RefPtr<SharedBuffer> SharedBuffer::create_with_size(int size) { void* data; - int shared_buffer_id = create_shared_buffer(peer, size, &data); + int shared_buffer_id = create_shared_buffer(size, &data); if (shared_buffer_id < 0) { perror("create_shared_buffer"); return nullptr; @@ -14,6 +14,16 @@ RefPtr<SharedBuffer> SharedBuffer::create(pid_t peer, int size) return adopt(*new SharedBuffer(shared_buffer_id, size, data)); } +bool SharedBuffer::share_with(pid_t peer) +{ + int ret = share_buffer_with(shared_buffer_id(), peer); + if (ret < 0) { + perror("share_buffer_with"); + return false; + } + return true; +} + RefPtr<SharedBuffer> SharedBuffer::create_from_shared_buffer_id(int shared_buffer_id) { void* data = get_shared_buffer(shared_buffer_id); |