+// This function is used to output the dump
+void wxDebugContext::OutputDumpLine(const wxChar *szFormat, ...)
+{
+    // a buffer of 2048 bytes should be long enough for a file name
+    // and a class name
+    wxChar buf[2048];
+    int count;
+    va_list argptr;
+    va_start(argptr, szFormat);
+    buf[sizeof(buf)/sizeof(wxChar)-1] = _T('\0');
+
+    // keep 3 bytes for a \r\n\0
+    count = wxVsnprintf(buf, sizeof(buf)/sizeof(wxChar)-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');
+
+    wxMessageOutputDebug dbgout;
+    dbgout.Printf(buf);
+}
+
+void wxDebugContext::SetShutdownNotifyFunction(wxShutdownNotifyFunction shutdownFn)
+{
+    sm_shutdownFn = shutdownFn;
+}
+
+
+#if USE_THREADSAFE_MEMORY_ALLOCATION
+static bool memSectionOk = false;
+
+class MemoryCriticalSection : public wxCriticalSection
+{
+public:
+    MemoryCriticalSection() {
+        memSectionOk = true;
+    }
+    ~MemoryCriticalSection() {
+        memSectionOk = false;
+    }
+};
+
+class MemoryCriticalSectionLocker
+{
+public:
+    inline MemoryCriticalSectionLocker(wxCriticalSection& critsect)
+    : m_critsect(critsect), m_locked(memSectionOk) { if(m_locked) m_critsect.Enter(); }
+    inline ~MemoryCriticalSectionLocker() { if(m_locked) m_critsect.Leave(); }
+
+private:
+    // no assignment operator nor copy ctor
+    MemoryCriticalSectionLocker(const MemoryCriticalSectionLocker&);
+    MemoryCriticalSectionLocker& operator=(const MemoryCriticalSectionLocker&);
+
+    wxCriticalSection& m_critsect;
+    bool m_locked;
+};
+
+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)
+{
+    return wxDebugAlloc(size, fileName, lineNum, false, false);
+}
+
+void * operator new (size_t size)
+{
+    return wxDebugAlloc(size, NULL, 0, false);
+}
+
+void operator delete (void * buf)
+{
+    wxDebugFree(buf, false);
+}
+
+#if wxUSE_ARRAY_MEMORY_OPERATORS
+void * operator new[] (size_t size)
+{
+    return wxDebugAlloc(size, NULL, 0, false, true);
+}
+
+void * operator new[] (size_t size, wxChar * fileName, int lineNum)
+{
+    return wxDebugAlloc(size, fileName, lineNum, false, true);
+}
+
+void operator delete[] (void * buf)
+{
+  wxDebugFree(buf, true);
+}
+#endif // wxUSE_ARRAY_MEMORY_OPERATORS
+#endif // wxUSE_GLOBAL_MEMORY_OPERATORS
+#endif // !(defined(__WXMSW__) && (defined(WXUSINGDLL) || defined(WXMAKINGDLL_BASE)))
+