diff options
author | Nicky <nicky.dasmijn@gmail.com> | 2022-06-13 20:09:42 +0200 |
---|---|---|
committer | Nicky <nicky.dasmijn@gmail.com> | 2022-06-13 20:09:42 +0200 |
commit | 1b73835d6e80bc64c520a8846aebdbe1b7c9705b (patch) | |
tree | b972275919bf6c620bbbcb81dd6b12568494561e /indra/llcommon/llrefcount.h | |
parent | 78e069f5e8ef1ee312e709934482b23aa86a69c2 (diff) | |
parent | c08a61453b21664da3687661512e2ea208f90d98 (diff) |
Merge branch 'DRTVWR-543-maint_cmake' of bitbucket.org:NickyD/viewer-cmake into DRTVWR-543-maint_cmake
Diffstat (limited to 'indra/llcommon/llrefcount.h')
-rw-r--r-- | indra/llcommon/llrefcount.h | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/indra/llcommon/llrefcount.h b/indra/llcommon/llrefcount.h index 7e4af6ea66..2080da1565 100644 --- a/indra/llcommon/llrefcount.h +++ b/indra/llcommon/llrefcount.h @@ -37,6 +37,10 @@ class LLMutex; // see llthread.h for LLThreadSafeRefCount //---------------------------------------------------------------------------- +//nonsense but recognizable value for freed LLRefCount (aids in debugging) +#define LL_REFCOUNT_FREE 1234567890 +extern const S32 gMaxRefCount; + class LL_COMMON_API LLRefCount { protected: @@ -47,17 +51,25 @@ protected: public: LLRefCount(); + inline void validateRefCount() const + { + llassert(mRef > 0); // ref count below 0, likely corrupted + llassert(mRef < gMaxRefCount); // ref count excessive, likely memory leak + } + inline void ref() const { mRef++; + validateRefCount(); } inline S32 unref() const { - llassert(mRef >= 1); + validateRefCount(); if (0 == --mRef) { - delete this; + mRef = LL_REFCOUNT_FREE; // set to nonsense yet recognizable value to aid in debugging + delete this; return 0; } return mRef; |