mirror of
https://github.com/minetest/minetest.git
synced 2024-12-22 22:22:23 +01:00
Prevent accidentally copy/move of refcounted objects
This commit is contained in:
parent
62131fe295
commit
3fb4049612
@ -51,6 +51,10 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
// Reference counted objects can be neither copied nor moved.
|
||||
IReferenceCounted(const IReferenceCounted &) = delete;
|
||||
IReferenceCounted &operator=(const IReferenceCounted &) = delete;
|
||||
|
||||
//! Grabs the object. Increments the reference counter by one.
|
||||
/** Someone who calls grab() to an object, should later also
|
||||
call drop() to it. If an object never gets as much drop() as
|
||||
|
@ -273,9 +273,7 @@ public:
|
||||
void grab() noexcept { ++m_refcount; }
|
||||
void drop() noexcept { if (--m_refcount == 0) delete this; }
|
||||
|
||||
// Preserve own reference count.
|
||||
IntrusiveReferenceCounted(const IntrusiveReferenceCounted &) {}
|
||||
IntrusiveReferenceCounted &operator=(const IntrusiveReferenceCounted &) { return *this; }
|
||||
DISABLE_CLASS_COPY(IntrusiveReferenceCounted)
|
||||
private:
|
||||
u32 m_refcount = 1;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user