X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ca5e07c7683a6b4c63dc6d4d05c75ba46d0b0de8..b1f68ca3455436222b8704dccdecdb06087c4e7f:/include/wx/string.h diff --git a/include/wx/string.h b/include/wx/string.h index 852f67115b..d082d97b73 100644 --- a/include/wx/string.h +++ b/include/wx/string.h @@ -190,17 +190,19 @@ struct WXDLLEXPORT wxStringData // lock/unlock void Lock() { if ( !IsEmpty() ) nRefs++; } - // VC++ will refuse to inline this function but profiling shows that it - // is wrong + // VC++ will refuse to inline Unlock but profiling shows that it is wrong #if defined(__VISUALC__) && (__VISUALC__ >= 1200) __forceinline #endif - void Unlock() { if ( !IsEmpty() && --nRefs == 0) Free(); } - // VC++ free must take place in same DLL as allocation when using non dll // run-time library (e.g. Multithreaded instead of Multithreaded DLL) +#if defined(__VISUALC__) && defined(_MT) && !defined(_DLL) + void Unlock() { if ( !IsEmpty() && --nRefs == 0) Free(); } // we must not inline deallocation since allocation is not inlined void Free(); +#else + void Unlock() { if ( !IsEmpty() && --nRefs == 0) free(this); } +#endif // if we had taken control over string memory (GetWriteBuf), it's // intentionally put in invalid state