ladybird/Kernel/Memory/SharedInodeVMObject.cpp
Andreas Kling a1d7ebf85a Kernel: Rename Kernel/VM/ to Kernel/Memory/
This directory isn't just about virtual memory, it's about all kinds
of memory management.
2021-08-06 14:05:58 +02:00

39 lines
998 B
C++

/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <Kernel/FileSystem/Inode.h>
#include <Kernel/Memory/SharedInodeVMObject.h>
namespace Kernel {
RefPtr<SharedInodeVMObject> SharedInodeVMObject::try_create_with_inode(Inode& inode)
{
size_t size = inode.size();
if (auto shared_vmobject = inode.shared_vmobject())
return shared_vmobject.release_nonnull();
auto vmobject = adopt_ref_if_nonnull(new (nothrow) SharedInodeVMObject(inode, size));
if (!vmobject)
return nullptr;
vmobject->inode().set_shared_vmobject(*vmobject);
return vmobject;
}
RefPtr<VMObject> SharedInodeVMObject::try_clone()
{
return adopt_ref_if_nonnull(new (nothrow) SharedInodeVMObject(*this));
}
SharedInodeVMObject::SharedInodeVMObject(Inode& inode, size_t size)
: InodeVMObject(inode, size)
{
}
SharedInodeVMObject::SharedInodeVMObject(SharedInodeVMObject const& other)
: InodeVMObject(other)
{
}
}