+// 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);
+}
+
+
+#if USE_THREADSAFE_MEMORY_ALLOCATION
+static bool memSectionOk = false;
+
+class MemoryCriticalSection : public wxCriticalSection
+{
+public:
+ MemoryCriticalSection() {
+ memSectionOk = true;
+ }
+};
+
+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;
+};
+
+MemoryCriticalSection &GetMemLocker()
+{
+ static MemoryCriticalSection memLocker;
+ return memLocker;
+}
+
+#endif
+