]> git.saurik.com Git - apple/security.git/blobdiff - OSX/libsecurity_utilities/lib/refcount.h
Security-58286.260.20.tar.gz
[apple/security.git] / OSX / libsecurity_utilities / lib / refcount.h
index 677376c5c964e229dd387740fbbf6b0372fb6cc0..e94f565702342be65106b9932fb2fc2a95a611bf 100644 (file)
@@ -49,14 +49,15 @@ namespace Security {
 // way to "demand copy" a RefCount subclass. Trust me; it's been tried. Don't.
 //
 
 // 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
 
 #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
 #else
-# define RCDEBUG(kind) /* nothing */
+# define RCDEBUG_CREATE()         /* nothing */
+# define RCDEBUG(kind, _args...)  /* nothing */
 #endif
 
 
 #endif
 
 
@@ -65,7 +66,7 @@ namespace Security {
 //
 class RefCount {       
 public:
 //
 class RefCount {       
 public:
-       RefCount() : mRefCount(0) { RCDEBUG(CREATE); }
+       RefCount() : mRefCount(0) { RCDEBUG_CREATE(); }
 
 protected:
        template <class T> friend class RefPointer;
 
 protected:
        template <class T> friend class RefPointer;
@@ -81,9 +82,6 @@ protected:
         RCDEBUG(DOWN, mRefCount - 1);
         return OSAtomicDecrement32(&mRefCount);
     }
         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;
 
 private:
     volatile mutable int32_t mRefCount;