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

Kernel: Customize File::unref() and make it virtual

Make File inherit from RefCountedBase and provide a custom unref()
implementation. This will allow subclasses that participate in lists to
remove themselves in a safe way when being destroyed.
This commit is contained in:
Andreas Kling 2021-08-16 20:58:23 +02:00
parent fc0cd8317a
commit 641083f3b8
2 changed files with 10 additions and 1 deletions

View file

@ -20,6 +20,14 @@ File::~File()
{
}
bool File::unref() const
{
if (deref_base())
return false;
delete this;
return true;
}
KResultOr<NonnullRefPtr<FileDescription>> File::open(int options)
{
auto description = FileDescription::create(*this);