X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/aa75d6d98c2ca564d2a3a6892e2efeef789ef433..035fa7f78c8915a24114d26728fa805773f2c4b5:/src/common/memory.cpp?ds=sidebyside diff --git a/src/common/memory.cpp b/src/common/memory.cpp index e141d7a766..4253bae38e 100644 --- a/src/common/memory.cpp +++ b/src/common/memory.cpp @@ -16,7 +16,7 @@ #pragma hdrstop #endif -#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT +#if wxUSE_MEMORY_TRACING || wxUSE_DEBUG_CONTEXT #include "wx/memory.h" @@ -46,7 +46,7 @@ #include #include -#if wxUSE_THREADS && defined(__WXDEBUG__) +#if wxUSE_THREADS #define USE_THREADSAFE_MEMORY_ALLOCATION 1 #else #define USE_THREADSAFE_MEMORY_ALLOCATION 0 @@ -118,8 +118,9 @@ void wxMemStruct::ErrorMsg () */ int wxMemStruct::AssertList () { - if (wxDebugContext::GetHead () != 0 && ! (wxDebugContext::GetHead ())->AssertIt () || - wxDebugContext::GetTail () != 0 && ! wxDebugContext::GetTail ()->AssertIt ()) { + if ((wxDebugContext::GetHead() && !wxDebugContext::GetHead()->AssertIt()) || + (wxDebugContext::GetTail() && !wxDebugContext::GetTail()->AssertIt())) + { ErrorMsg ("Head or tail pointers trashed"); return 0; } @@ -575,26 +576,21 @@ void wxDebugContext::TraverseList (PmSFV func, wxMemStruct *from) */ bool wxDebugContext::PrintList (void) { -#ifdef __WXDEBUG__ - TraverseList ((PmSFV)&wxMemStruct::PrintNode, (checkPoint ? checkPoint->m_next : (wxMemStruct*)NULL)); + TraverseList ((PmSFV)&wxMemStruct::PrintNode, (checkPoint ? checkPoint->m_next : NULL)); return true; -#else - return false; -#endif } bool wxDebugContext::Dump(void) { -#ifdef __WXDEBUG__ { const wxChar* appName = wxT("application"); wxString appNameStr; if (wxTheApp) { appNameStr = wxTheApp->GetAppName(); - appName = appNameStr; - OutputDumpLine(wxT("----- Memory dump of %s at %s -----"), appName, (const wxChar *)wxNow() ); + appName = appNameStr.c_str(); + OutputDumpLine(wxT("----- Memory dump of %s at %s -----"), appName, static_cast(wxNow().c_str())); } else { @@ -602,18 +598,14 @@ bool wxDebugContext::Dump(void) } } - TraverseList ((PmSFV)&wxMemStruct::Dump, (checkPoint ? checkPoint->m_next : (wxMemStruct*)NULL)); + TraverseList ((PmSFV)&wxMemStruct::Dump, (checkPoint ? checkPoint->m_next : NULL)); OutputDumpLine(wxEmptyString); OutputDumpLine(wxEmptyString); return true; -#else - return false; -#endif } -#ifdef __WXDEBUG__ struct wxDebugStatsStruct { long instanceCount; @@ -638,19 +630,17 @@ static wxDebugStatsStruct *InsertStatsStruct(wxDebugStatsStruct *head, wxDebugSt st->next = head; return st; } -#endif bool wxDebugContext::PrintStatistics(bool detailed) { -#ifdef __WXDEBUG__ { const wxChar* appName = wxT("application"); wxString appNameStr; if (wxTheApp) { appNameStr = wxTheApp->GetAppName(); - appName = appNameStr; - OutputDumpLine(wxT("----- Memory statistics of %s at %s -----"), appName, (const wxChar *) wxNow() ); + appName = appNameStr.c_str(); + OutputDumpLine(wxT("----- Memory statistics of %s at %s -----"), appName, static_cast(wxNow().c_str())); } else { @@ -667,7 +657,7 @@ bool wxDebugContext::PrintStatistics(bool detailed) wxDebugStatsStruct *list = NULL; - wxMemStruct *from = (checkPoint ? checkPoint->m_next : (wxMemStruct*)NULL ); + wxMemStruct *from = (checkPoint ? checkPoint->m_next : NULL ); if (!from) from = wxDebugContext::GetHead (); @@ -729,10 +719,6 @@ bool wxDebugContext::PrintStatistics(bool detailed) OutputDumpLine(wxEmptyString); return true; -#else - (void)detailed; - return false; -#endif } bool wxDebugContext::PrintClasses(void) @@ -743,7 +729,7 @@ bool wxDebugContext::PrintClasses(void) if (wxTheApp) { appNameStr = wxTheApp->GetAppName(); - appName = appNameStr; + appName = appNameStr.c_str(); wxLogMessage(wxT("----- Classes in %s -----"), appName); } } @@ -800,7 +786,7 @@ int wxDebugContext::Check(bool checkAll) { int nFailures = 0; - wxMemStruct *from = (checkPoint ? checkPoint->m_next : (wxMemStruct*)NULL ); + wxMemStruct *from = (checkPoint ? checkPoint->m_next : NULL ); if (!from || checkAll) from = wxDebugContext::GetHead (); @@ -846,16 +832,16 @@ void wxDebugContext::OutputDumpLine(const wxChar *szFormat, ...) int count; va_list argptr; va_start(argptr, szFormat); - buf[sizeof(buf)/sizeof(wxChar)-1] = _T('\0'); + buf[WXSIZEOF(buf)-1] = wxT('\0'); // keep 3 bytes for a \r\n\0 - count = wxVsnprintf(buf, sizeof(buf)/sizeof(wxChar)-3, szFormat, argptr); + count = wxVsnprintf(buf, WXSIZEOF(buf)-3, szFormat, argptr); if ( count < 0 ) - count = sizeof(buf)/sizeof(wxChar)-3; - buf[count]=_T('\r'); - buf[count+1]=_T('\n'); - buf[count+2]=_T('\0'); + count = WXSIZEOF(buf)-3; + buf[count]=wxT('\r'); + buf[count+1]=wxT('\n'); + buf[count+2]=wxT('\0'); wxMessageOutputDebug dbgout; dbgout.Printf(buf); @@ -902,7 +888,6 @@ static MemoryCriticalSection memLocker; #endif // USE_THREADSAFE_MEMORY_ALLOCATION -#ifdef __WXDEBUG__ #if !(defined(__WXMSW__) && (defined(WXUSINGDLL) || defined(WXMAKINGDLL_BASE))) #if wxUSE_GLOBAL_MEMORY_OPERATORS void * operator new (size_t size, wxChar * fileName, int lineNum) @@ -1049,8 +1034,6 @@ void wxDebugFree(void * buf, bool WXUNUSED(isVect) ) free((char *)st); } -#endif // __WXDEBUG__ - // Trace: send output to the current debugging stream void wxTrace(const wxChar * ...) { @@ -1167,4 +1150,4 @@ void wxDebugContextDumpDelayCounter::DoDump() // least one cleanup counter object static wxDebugContextDumpDelayCounter wxDebugContextDumpDelayCounter_One; -#endif // (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT +#endif // wxUSE_MEMORY_TRACING || wxUSE_DEBUG_CONTEXT