X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/223d09f6b523aac674ef9b72a883dfa8d37c5d4e..5824f314a3ac14fb4f4c8c2db7823076fedbbee8:/src/common/memory.cpp diff --git a/src/common/memory.cpp b/src/common/memory.cpp index d8ad194662..a67263d476 100644 --- a/src/common/memory.cpp +++ b/src/common/memory.cpp @@ -35,7 +35,7 @@ #include "wx/app.h" #endif -#include +#include "wx/log.h" #include #include "wx/ioswrap.h" @@ -46,7 +46,8 @@ #include #endif -#if !defined(__WATCOMC__) && !defined(__VMS__) && !defined( __MWERKS__ ) && !defined(__SALFORDC__) +#if !defined(__WATCOMC__) && !(defined(__VMS__) && ( __VMS_VER < 70000000 ) )\ + && !defined( __MWERKS__ ) && !defined(__SALFORDC__) #include #endif @@ -472,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; @@ -595,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) { @@ -602,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 } /* @@ -988,6 +1008,7 @@ void * operator new[] (size_t size, wxChar * fileName, int lineNum) } #endif +#if !defined(__VISAGECPP__) // already defines this by default void operator delete (void * buf) { #ifdef NO_DEBUG_ALLOCATION @@ -996,13 +1017,12 @@ void operator delete (void * buf) wxDebugFree(buf); #endif } +#endif // VC++ 6.0 #if defined(__VISUALC__) && (__VISUALC__ >= 1200) void operator delete(void* pData, wxChar* /* fileName */, int /* lineNum */) { -// ::operator delete(pData); - // JACS 21/11/1998: surely we need to call wxDebugFree? wxDebugFree(pData, FALSE); } // New operator 21/11/1998