class MemoryCriticalSection : public wxCriticalSection
{
public:
- MemoryCriticalSection() {
- memSectionOk = true;
- }
+ MemoryCriticalSection() {
+ memSectionOk = true;
+ }
};
class MemoryCriticalSectionLocker
{
public:
inline MemoryCriticalSectionLocker(wxCriticalSection& critsect)
- : m_critsect(critsect), m_locked(memSectionOk) { if(m_locked) m_critsect.Enter(); }
+ : m_critsect(critsect), m_locked(memSectionOk) { if(m_locked) m_critsect.Enter(); }
inline ~MemoryCriticalSectionLocker() { if(m_locked) m_critsect.Leave(); }
private:
MemoryCriticalSectionLocker& operator=(const MemoryCriticalSectionLocker&);
wxCriticalSection& m_critsect;
- bool m_locked;
+ bool m_locked;
};
-static MemoryCriticalSection memLocker;
+MemoryCriticalSection &GetMemLocker()
+{
+ static MemoryCriticalSection memLocker;
+ return memLocker;
+}
+
#endif
// TODO: store whether this is a vector or not.
void * wxDebugAlloc(size_t size, wxChar * fileName, int lineNum, bool isObject, bool WXUNUSED(isVect) )
{
#if USE_THREADSAFE_MEMORY_ALLOCATION
- MemoryCriticalSectionLocker lock(memLocker);
+ MemoryCriticalSectionLocker lock(GetMemLocker());
#endif
// If not in debugging allocation mode, do the normal thing
void wxDebugFree(void * buf, bool WXUNUSED(isVect) )
{
#if USE_THREADSAFE_MEMORY_ALLOCATION
- MemoryCriticalSectionLocker lock(memLocker);
+ MemoryCriticalSectionLocker lock(GetMemLocker());
#endif
if (!buf)