17 #ifndef DISTRHO_LEAK_DETECTOR_HPP_INCLUDED 
   18 #define DISTRHO_LEAK_DETECTOR_HPP_INCLUDED 
   20 #include "../DistrhoUtils.hpp" 
   22 START_NAMESPACE_DISTRHO
 
   32 #define DISTRHO_JOIN_MACRO_HELPER(a, b) a ## b 
   33 #define DISTRHO_JOIN_MACRO(item1, item2) DISTRHO_JOIN_MACRO_HELPER(item1, item2) 
   51 # define DISTRHO_LEAK_DETECTOR(ClassName)                                         \ 
   52     friend class DISTRHO_NAMESPACE::LeakedObjectDetector<ClassName>;              \ 
   53     static const char* getLeakedObjectClassName() noexcept { return #ClassName; } \ 
   54     DISTRHO_NAMESPACE::LeakedObjectDetector<ClassName> DISTRHO_JOIN_MACRO(leakDetector_, ClassName); 
   56 # define DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ClassName) \ 
   57     DISTRHO_DECLARE_NON_COPYABLE(ClassName)                       \ 
   58     DISTRHO_LEAK_DETECTOR(ClassName) 
   61 # define DISTRHO_LEAK_DETECTOR(ClassName) 
   62 # define DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ClassName) \ 
   63     DISTRHO_DECLARE_NON_COPYABLE(ClassName) 
   78 template<
class OwnerClass>
 
   88         if (--(getCounter().numObjects) < 0)
 
  101             d_stderr2(
"*** Dangling pointer deletion! Class: '%s', Count: %i", getLeakedObjectClassName(), getCounter().numObjects);
 
  110         LeakCounter() noexcept
 
  113         ~LeakCounter() noexcept
 
  124                 d_stderr2(
"*** Leaked objects detected: %i instance(s) of class '%s'", numObjects, getLeakedObjectClassName());
 
  129         volatile int numObjects;
 
  132     static const char* getLeakedObjectClassName() noexcept
 
  134         return OwnerClass::getLeakedObjectClassName();
 
  137     static LeakCounter& getCounter() noexcept
 
  139         static LeakCounter counter;
 
  146 END_NAMESPACE_DISTRHO
 
  148 #endif // DISTRHO_LEAK_DETECTOR_HPP_INCLUDED