X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/5c19dc3ae3bd8e40a9c028b0deddd50ff337692c..7e6b461318c8a779d91381531435a68ee4e8b6ed:/OSX/libsecurity_utilities/lib/refcount.h?ds=sidebyside diff --git a/OSX/libsecurity_utilities/lib/refcount.h b/OSX/libsecurity_utilities/lib/refcount.h index 677376c5..e94f5657 100644 --- a/OSX/libsecurity_utilities/lib/refcount.h +++ b/OSX/libsecurity_utilities/lib/refcount.h @@ -49,14 +49,15 @@ namespace Security { // way to "demand copy" a RefCount subclass. Trust me; it's been tried. Don't. // -#if !defined(DEBUG_REFCOUNTS) -# define DEBUG_REFCOUNTS 1 -#endif +// Uncomment to debug refcounts +//# define DEBUG_REFCOUNTS 1 #if DEBUG_REFCOUNTS -# define RCDEBUG(_kind, _args...) SECURITY_DEBUG_REFCOUNT_##_kind((void *)this, ##_args) +# define RCDEBUG_CREATE() secinfo("refcount", "%p: CREATE", this) +# define RCDEBUG(_kind, n) secinfo("refcount", "%p: %s: %d", this, #_kind, n) #else -# define RCDEBUG(kind) /* nothing */ +# define RCDEBUG_CREATE() /* nothing */ +# define RCDEBUG(kind, _args...) /* nothing */ #endif @@ -65,7 +66,7 @@ namespace Security { // class RefCount { public: - RefCount() : mRefCount(0) { RCDEBUG(CREATE); } + RefCount() : mRefCount(0) { RCDEBUG_CREATE(); } protected: template friend class RefPointer; @@ -81,9 +82,6 @@ protected: RCDEBUG(DOWN, mRefCount - 1); return OSAtomicDecrement32(&mRefCount); } - - // if you call this for anything but debug output, you will go to hell (free handbasket included) - unsigned int refCountForDebuggingOnly() const { return mRefCount; } private: volatile mutable int32_t mRefCount;