17 #ifndef DISTRHO_LEAK_DETECTOR_HPP_INCLUDED
18 #define DISTRHO_LEAK_DETECTOR_HPP_INCLUDED
20 #include "../DistrhoUtils.hpp"
50 #define DISTRHO_JOIN_MACRO_HELPER(a, b) a ## b
51 #define DISTRHO_JOIN_MACRO(item1, item2) DISTRHO_JOIN_MACRO_HELPER(item1, item2)
53 #if defined(DPF_DEBUG) && !defined(NDEBUG)
69 # define DISTRHO_LEAK_DETECTOR(ClassName) \
70 friend class DISTRHO_NAMESPACE::LeakedObjectDetector<ClassName>; \
71 static const char* getLeakedObjectClassName() noexcept { return #ClassName; } \
72 DISTRHO_NAMESPACE::LeakedObjectDetector<ClassName> DISTRHO_JOIN_MACRO(leakDetector_, ClassName);
74 # define DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ClassName) \
75 DISTRHO_DECLARE_NON_COPYABLE(ClassName) \
76 DISTRHO_LEAK_DETECTOR(ClassName)
79 # define DISTRHO_LEAK_DETECTOR(ClassName)
80 # define DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ClassName) \
81 DISTRHO_DECLARE_NON_COPYABLE(ClassName)
96 template<
class OwnerClass>
106 if (--(getCounter().numObjects) < 0)
119 d_stderr2(
"*** Dangling pointer deletion! Class: '%s', Count: %i", getLeakedObjectClassName(), getCounter().numObjects);
128 LeakCounter() noexcept
131 ~LeakCounter() noexcept
142 d_stderr2(
"*** Leaked objects detected: %i instance(s) of class '%s'", numObjects, getLeakedObjectClassName());
147 volatile int numObjects;
150 static const char* getLeakedObjectClassName() noexcept
152 return OwnerClass::getLeakedObjectClassName();
155 static LeakCounter& getCounter() noexcept
157 static LeakCounter counter;
Definition: LeakDetector.hpp:98
~LeakedObjectDetector() noexcept
Definition: LeakDetector.hpp:104
#define END_NAMESPACE_DISTRHO
Definition: DistrhoInfo.hpp:949
#define START_NAMESPACE_DISTRHO
Definition: DistrhoInfo.hpp:943
static void d_stderr2(const char *const fmt,...) noexcept
Definition: DistrhoUtils.hpp:171