From: Andreas Monzner Date: Thu, 17 Aug 2006 13:13:53 +0000 (+0000) Subject: fix memleak check X-Git-Tag: 2.6.0~3063 X-Git-Url: https://git.cweiske.de/enigma2.git/commitdiff_plain/3f7b163cb754f07ffbf8279a9b8e9f3c8daf526c fix memleak check cleanup --- diff --git a/lib/base/eerror.h b/lib/base/eerror.h index 4289ab30..e7c33a0b 100644 --- a/lib/base/eerror.h +++ b/lib/base/eerror.h @@ -17,33 +17,6 @@ #include #include #include -#endif // MEMLEAK_CHECK - -#ifndef NULL -#define NULL 0 -#endif - -#ifdef ASSERT -#undef ASSERT -#endif - -#ifndef SWIG - -#define CHECKFORMAT __attribute__ ((__format__(__printf__, 1, 2))) - -extern Signal2 logOutput; -extern int logOutputConsole; - -void CHECKFORMAT eFatal(const char*, ...); -enum { lvlDebug=1, lvlWarning=2, lvlFatal=4 }; - -#ifdef DEBUG - void CHECKFORMAT eDebug(const char*, ...); - void CHECKFORMAT eDebugNoNewLine(const char*, ...); - void CHECKFORMAT eWarning(const char*, ...); - #define ASSERT(x) { if (!(x)) eFatal("%s:%d ASSERTION %s FAILED!", __FILE__, __LINE__, #x); } - -#ifdef MEMLEAK_CHECK typedef struct { unsigned int address; @@ -127,6 +100,29 @@ void DumpUnfreed(); #endif // MEMLEAK_CHECK +#ifndef NULL +#define NULL 0 +#endif + +#ifdef ASSERT +#undef ASSERT +#endif + +#ifndef SWIG + +#define CHECKFORMAT __attribute__ ((__format__(__printf__, 1, 2))) + +extern Signal2 logOutput; +extern int logOutputConsole; + +void CHECKFORMAT eFatal(const char*, ...); +enum { lvlDebug=1, lvlWarning=2, lvlFatal=4 }; + +#ifdef DEBUG + void CHECKFORMAT eDebug(const char*, ...); + void CHECKFORMAT eDebugNoNewLine(const char*, ...); + void CHECKFORMAT eWarning(const char*, ...); + #define ASSERT(x) { if (!(x)) eFatal("%s:%d ASSERTION %s FAILED!", __FILE__, __LINE__, #x); } #else // DEBUG inline void eDebug(const char* fmt, ...) { diff --git a/lib/base/object.h b/lib/base/object.h index d0e2a65e..7f823223 100644 --- a/lib/base/object.h +++ b/lib/base/object.h @@ -31,9 +31,13 @@ public: volatile int count; oRefCount(): count(0) { } operator volatile int&() { return count; } - ~oRefCount() { + ~oRefCount() + { #ifdef OBJECT_DEBUG - if (count) eDebug("OBJECT_DEBUG FATAL: %p has %d references!", this, count); else eDebug("OBJECT_DEBUG refcount ok! (%p)", this); + if (count) + eDebug("OBJECT_DEBUG FATAL: %p has %d references!", this, count); + else + eDebug("OBJECT_DEBUG refcount ok! (%p)", this); #endif } }; @@ -139,6 +143,7 @@ public: delete this; \ } #else + #warning use non optimized implementation of refcounting. #define DECLARE_REF(x) \ private:oRefCount ref; \ eSingleLock ref_lock; \