X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/0103839d01b8762a836265695cee4efbecc057da..765e1c0b8f36ea3909fc0a3883f68d56d0d5530f:/lib/base/eerror.h diff --git a/lib/base/eerror.h b/lib/base/eerror.h index 4289ab30..6040565e 100644 --- a/lib/base/eerror.h +++ b/lib/base/eerror.h @@ -17,38 +17,11 @@ #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; unsigned int size; - char *file; + const char *file; void *backtrace[BACKTRACE_DEPTH]; unsigned char btcount; unsigned short line; @@ -68,11 +41,11 @@ static inline void AddTrack(unsigned int addr, unsigned int asize, const char allocList = new(AllocList); info.address = addr; - info.file = strdup(fname); + info.file = fname; info.line = lnum; info.size = asize; info.type = type; - info.btcount = backtrace( info.backtrace, BACKTRACE_DEPTH ); + info.btcount = 0; //backtrace( info.backtrace, BACKTRACE_DEPTH ); singleLock s(memLock); (*allocList)[addr]=info; }; @@ -89,14 +62,11 @@ static inline void RemoveTrack(unsigned int addr, unsigned int type) if ( i->second.type != type ) i->second.type=3; else - { - free(i->second.file); allocList->erase(i); - } } }; -inline void * operator new(unsigned int size, const char *file, int line) +inline void * operator new(size_t size, const char *file, int line) { void *ptr = (void *)malloc(size); AddTrack((unsigned int)ptr, size, file, line, 1); @@ -109,7 +79,7 @@ inline void operator delete(void *p) free(p); }; -inline void * operator new[](unsigned int size, const char *file, int line) +inline void * operator new[](size_t size, const char *file, int line) { void *ptr = (void *)malloc(size); AddTrack((unsigned int)ptr, size, file, line, 2); @@ -127,6 +97,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, ...) {