InspIRCd
3.0
|
#include <base.h>
Public Member Functions | |
unsigned int | GetReferenceCount () const |
void | refcount_inc () const |
bool | refcount_dec () const |
Static Public Member Functions | |
static void * | operator new (size_t, void *m) |
static void * | operator new (size_t) |
static void | operator delete (void *) |
The base class for inspircd classes that support reference counting. Any objects that do not have a well-defined lifetime should inherit from this, and should be assigned to a reference<type> object to establish their lifetime.
Reference objects should not hold circular references back to themselves, even indirectly; this will cause a memory leak because the count will never drop to zero.
Using a normal pointer for the object is recommended if you can assure that at least one reference<> will remain as long as that pointer is used; this will avoid the slight overhead of changing the reference count.