fix memleak check
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Thu, 17 Aug 2006 13:13:53 +0000 (13:13 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Thu, 17 Aug 2006 13:13:53 +0000 (13:13 +0000)
cleanup

lib/base/eerror.h
lib/base/object.h

index 4289ab3..e7c33a0 100644 (file)
 #include <string>
 #include <new>
 #include <cxxabi.h>
-#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<void, int, const std::string&> 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<void, int, const std::string&> 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, ...)
     {
index d0e2a65..7f82322 100644 (file)
@@ -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; \