X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/aaf1bbfd62a0297da30d2ac01f6e30592a3d11e0..0b1cc7bffb94ebfb4bc988b9a7320b96ea0cfcda:/src/common/memory.cpp diff --git a/src/common/memory.cpp b/src/common/memory.cpp index 0d67e157e0..72169f2735 100644 --- a/src/common/memory.cpp +++ b/src/common/memory.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: memory.cpp +// Name: src/common/memory.cpp // Purpose: Memory checking implementation // Author: Arthur Seaton, Julian Smart // Modified by: @@ -9,38 +9,31 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) -#pragma implementation "memory.h" -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" #ifdef __BORLANDC__ -#pragma hdrstop -#endif - -#ifndef WX_PRECOMP -#include "wx/defs.h" + #pragma hdrstop #endif #if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) -// #pragma implementation -#endif +#include "wx/memory.h" #ifndef WX_PRECOMP -#include "wx/utils.h" -#include "wx/app.h" -#include "wx/hash.h" + #ifdef __WXMSW__ + #include "wx/msw/wrapwin.h" + #endif + #include "wx/utils.h" + #include "wx/app.h" + #include "wx/hash.h" + #include "wx/log.h" #endif #if wxUSE_THREADS -#include "wx/thread.h" + #include "wx/thread.h" #endif -#include "wx/log.h" #include #include "wx/ioswrap.h" @@ -53,21 +46,6 @@ #include #include -#ifdef __WXMSW__ -#include "wx/msw/wrapwin.h" - -#ifdef GetClassInfo -#undef GetClassInfo -#endif - -#ifdef GetClassName -#undef GetClassName -#endif - -#endif - -#include "wx/memory.h" - #if wxUSE_THREADS && defined(__WXDEBUG__) #define USE_THREADSAFE_MEMORY_ALLOCATION 1 #else @@ -892,6 +870,9 @@ public: MemoryCriticalSection() { memSectionOk = true; } + ~MemoryCriticalSection() { + memSectionOk = false; + } }; class MemoryCriticalSectionLocker @@ -910,10 +891,14 @@ private: bool m_locked; }; - static MemoryCriticalSection memLocker; +static MemoryCriticalSection memLocker; + +#endif // USE_THREADSAFE_MEMORY_ALLOCATION -#endif +#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) { return wxDebugAlloc(size, fileName, lineNum, false, false); @@ -944,7 +929,9 @@ void operator delete[] (void * buf) { wxDebugFree(buf, true); } -#endif +#endif // wxUSE_ARRAY_MEMORY_OPERATORS +#endif // wxUSE_GLOBAL_MEMORY_OPERATORS +#endif // !(defined(__WXMSW__) && (defined(WXUSINGDLL) || defined(WXMAKINGDLL_BASE))) // TODO: store whether this is a vector or not. void * wxDebugAlloc(size_t size, wxChar * fileName, int lineNum, bool isObject, bool WXUNUSED(isVect) ) @@ -1056,6 +1043,8 @@ void wxDebugFree(void * buf, bool WXUNUSED(isVect) ) free((char *)st); } +#endif // __WXDEBUG__ + // Trace: send output to the current debugging stream void wxTrace(const wxChar * ...) { @@ -1134,11 +1123,11 @@ void wxTraceLevel(int, const wxChar * ...) } //---------------------------------------------------------------------------- -// Final cleanup after all global objects in all files have been destructed +// Final cleanup after all global objects in all files have been destroyed //---------------------------------------------------------------------------- // Don't set it to 0 by dynamic initialization -// Some compilers will realy do the asignment later +// Some compilers will really do the assignment later // All global variables are initialized to 0 at the very beginning, and this is just fine. int wxDebugContextDumpDelayCounter::sm_count; @@ -1153,8 +1142,7 @@ void wxDebugContextDumpDelayCounter::DoDump() } // Even if there is nothing else, make sure that there is at -// least one clenup counter object +// least one cleanup counter object static wxDebugContextDumpDelayCounter wxDebugContextDumpDelayCounter_One; #endif // (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT -