X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b40b0f5b204d59bbc1d3e66c5bba192b878469a6..6342bd1ab36c1957684c00d408d09fba65d33db6:/src/common/memory.cpp diff --git a/src/common/memory.cpp b/src/common/memory.cpp index d30fc10ee8..902a88a2f2 100644 --- a/src/common/memory.cpp +++ b/src/common/memory.cpp @@ -111,7 +111,7 @@ */ void wxMemStruct::ErrorMsg (const char * mesg) { - wxLogDebug(wxT("wxWindows memory checking error: %s"), mesg); + wxLogMessage(wxT("wxWindows memory checking error: %s"), mesg); PrintNode (); // << m_fileName << ' ' << m_lineNum << endl; @@ -122,7 +122,7 @@ void wxMemStruct::ErrorMsg (const char * mesg) */ void wxMemStruct::ErrorMsg () { - wxLogDebug(wxT("wxWindows over/underwrite memory error:")); + wxLogMessage(wxT("wxWindows over/underwrite memory error:")); PrintNode (); // cerr << m_fileName << ' ' << m_lineNum << endl; @@ -344,7 +344,7 @@ void wxMemStruct::PrintNode () msg2.Printf(wxT(" at $%lX, size %d"), (long)GetActualData(), (int)RequestSize()); msg += msg2; - wxLogDebug(msg); + wxLogMessage(msg); } else { @@ -357,7 +357,7 @@ void wxMemStruct::PrintNode () msg2.Printf(wxT(" at $%lX, size %d\n"), (long)GetActualData(), (int)RequestSize()); msg += msg2; - wxLogDebug(msg); + wxLogMessage(msg); } } @@ -390,7 +390,7 @@ void wxMemStruct::Dump () msg2.Printf(wxT(" at $%lX, size %d"), (long)GetActualData(), (int)RequestSize()); msg += msg2; - wxLogDebug(msg); + wxLogMessage(msg); } else { @@ -401,7 +401,7 @@ void wxMemStruct::Dump () wxString msg2(""); msg2.Printf(wxT("non-object data at $%lX, size %d"), (long)GetActualData(), (int)RequestSize() ); msg += msg2; - wxLogDebug(msg); + wxLogMessage(msg); } } @@ -419,7 +419,7 @@ int wxMemStruct::ValidateNode () else { // Can't use the error routines as we have no recognisable object. #ifndef __WXGTK__ - wxLogDebug(wxT("Can't verify memory struct - all bets are off!")); + wxLogMessage(wxT("Can't verify memory struct - all bets are off!")); #endif } return 0; @@ -473,6 +473,11 @@ int wxDebugContext::debugLevel = 1; bool wxDebugContext::debugOn = TRUE; wxMemStruct *wxDebugContext::checkPoint = NULL; +// For faster alignment calculation +static wxMarkerType markerCalc[2]; +int wxDebugContext::m_balign = (int)((char *)&markerCalc[1] - (char*)&markerCalc[0]); +int wxDebugContext::m_balignmask = (int)((char *)&markerCalc[1] - (char*)&markerCalc[0]) - 1; + wxDebugContext::wxDebugContext(void) { // m_streamBuf = new wxDebugStreamBuf; @@ -514,7 +519,7 @@ void wxDebugContext::SetStream(ostream *str, streambuf *buf) bool wxDebugContext::SetFile(const wxString& file) { - ofstream *str = new ofstream(file.fn_str()); + ofstream *str = new ofstream(file.mb_str()); if (str->bad()) { @@ -596,6 +601,9 @@ char * wxDebugContext::StartPos (const char * caller) I don't know how portable this stuff is, but it seems to work for me at the moment. It would be real nice if I knew more about this! + + // Note: this function is now obsolete (along with CalcAlignment) + // because the calculations are done statically, for greater speed. */ size_t wxDebugContext::GetPadding (const size_t size) { @@ -603,11 +611,22 @@ size_t wxDebugContext::GetPadding (const size_t size) return (pad) ? sizeof(wxMarkerType) - pad : 0; } - - size_t wxDebugContext::PaddedSize (const size_t size) { + // Added by Terry Farnham to replace + // slow GetPadding call. + int padb; + + padb = size & m_balignmask; + if(padb) + return(size + m_balign - padb); + else + return(size); + +// Old (slow) code +#if 0 return size + GetPadding (size); +#endif } /* @@ -673,17 +692,17 @@ bool wxDebugContext::Dump(void) { appNameStr = wxTheApp->GetAppName(); appName = WXSTRINGCAST appNameStr; - wxLogDebug(wxT("----- Memory dump of %s at %s -----"), appName, WXSTRINGCAST wxNow() ); + wxLogMessage(wxT("----- Memory dump of %s at %s -----"), appName, WXSTRINGCAST wxNow() ); } else { - wxLogDebug( wxT("----- Memory dump -----") ); + wxLogMessage( wxT("----- Memory dump -----") ); } } TraverseList ((PmSFV)&wxMemStruct::Dump, (checkPoint ? checkPoint->m_next : (wxMemStruct*)NULL)); - wxLogDebug( wxT("") ); - wxLogDebug( wxT("") ); + wxLogMessage( wxT("") ); + wxLogMessage( wxT("") ); return TRUE; #else @@ -730,11 +749,11 @@ bool wxDebugContext::PrintStatistics(bool detailed) { appNameStr = wxTheApp->GetAppName(); appName = WXSTRINGCAST appNameStr; - wxLogDebug(wxT("----- Memory statistics of %s at %s -----"), appName, WXSTRINGCAST wxNow() ); + wxLogMessage(wxT("----- Memory statistics of %s at %s -----"), appName, WXSTRINGCAST wxNow() ); } else { - wxLogDebug( wxT("----- Memory statistics -----") ); + wxLogMessage( wxT("----- Memory statistics -----") ); } } @@ -793,22 +812,22 @@ bool wxDebugContext::PrintStatistics(bool detailed) { while (list) { - wxLogDebug(wxT("%ld objects of class %s, total size %ld"), + wxLogMessage(wxT("%ld objects of class %s, total size %ld"), list->instanceCount, list->instanceClass, list->totalSize); wxDebugStatsStruct *old = list; list = old->next; free((char *)old); } - wxLogDebug(wxT("")); + wxLogMessage(wxT("")); } SetDebugMode(currentMode); - wxLogDebug(wxT("Number of object items: %ld"), noObjectNodes); - wxLogDebug(wxT("Number of non-object items: %ld"), noNonObjectNodes); - wxLogDebug(wxT("Total allocated size: %ld"), totalSize); - wxLogDebug(wxT("")); - wxLogDebug(wxT("")); + wxLogMessage(wxT("Number of object items: %ld"), noObjectNodes); + wxLogMessage(wxT("Number of non-object items: %ld"), noNonObjectNodes); + wxLogMessage(wxT("Total allocated size: %ld"), totalSize); + wxLogMessage(wxT("")); + wxLogMessage(wxT("")); return TRUE; #else @@ -829,7 +848,7 @@ bool wxDebugContext::PrintClasses(void) { appNameStr = wxTheApp->GetAppName(); appName = WXSTRINGCAST appNameStr; - wxLogDebug(wxT("----- Classes in %s -----"), appName); + wxLogMessage(wxT("----- Classes in %s -----"), appName); } } @@ -862,15 +881,15 @@ bool wxDebugContext::PrintClasses(void) if (info->GetConstructor()) msg += wxT(": dynamic"); - wxLogDebug(msg); + wxLogMessage(msg); } node = wxClassInfo::sm_classTable->Next(); n ++; } - wxLogDebug(wxT("")); - wxLogDebug(wxT("There are %d classes derived from wxObject."), n); - wxLogDebug(wxT("")); - wxLogDebug(wxT("")); + wxLogMessage(wxT("")); + wxLogMessage(wxT("There are %d classes derived from wxObject."), n); + wxLogMessage(wxT("")); + wxLogMessage(wxT("")); return TRUE; } @@ -1007,7 +1026,7 @@ void operator delete(void* pData, wxChar* /* fileName */, int /* lineNum */) wxDebugFree(pData, FALSE); } // New operator 21/11/1998 -void operator delete[](void* pData, char* /* fileName */, int /* lineNum */) +void operator delete[](void* pData, wxChar* /* fileName */, int /* lineNum */) { wxDebugFree(pData, TRUE); } @@ -1041,7 +1060,7 @@ void * wxDebugAlloc(size_t size, wxChar * fileName, int lineNum, bool isObject, int totSize = wxDebugContext::TotSize (size); char * buf = (char *) malloc(totSize); if (!buf) { - wxLogDebug(wxT("Call to malloc (%ld) failed."), (long)size); + wxLogMessage(wxT("Call to malloc (%ld) failed."), (long)size); return 0; } wxMemStruct * st = (wxMemStruct *)buf; @@ -1127,7 +1146,10 @@ void wxDebugFree(void * buf, bool WXUNUSED(isVect) ) // Trace: send output to the current debugging stream void wxTrace(const wxChar *fmt ...) { - va_list ap; +#if 1 + wxFAIL_MSG(wxT("wxTrace is now obsolete. Please use wxDebugXXX instead.")); +#else + va_list ap; static wxChar buffer[512]; va_start(ap, fmt); @@ -1155,11 +1177,15 @@ void wxTrace(const wxChar *fmt ...) #else fprintf(stderr, buffer); #endif +#endif } // Trace with level void wxTraceLevel(int level, const wxChar *fmt ...) { +#if 1 + wxFAIL_MSG(wxT("wxTrace is now obsolete. Please use wxDebugXXX instead.")); +#else if (wxDebugContext::GetLevel() < level) return; @@ -1169,7 +1195,7 @@ void wxTraceLevel(int level, const wxChar *fmt ...) va_start(ap, fmt); #ifdef __WXMSW__ - wvsprintf(buffer,fmt,ap) ; + wxWvsprintf(buffer,fmt,ap) ; #else vsprintf(buffer,fmt,ap) ; #endif @@ -1191,6 +1217,7 @@ void wxTraceLevel(int level, const wxChar *fmt ...) #else fprintf(stderr, buffer); #endif +#endif } #else // wxUSE_MEMORY_TRACING && defined(__WXDEBUG__)