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:
parent
fc0cd8317a
commit
641083f3b8
2 changed files with 10 additions and 1 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue