diff --git a/include/wx/string.h b/include/wx/string.h index b4a6fa1df7..852f67115b 100644 --- a/include/wx/string.h +++ b/include/wx/string.h @@ -195,7 +195,12 @@ struct WXDLLEXPORT wxStringData #if defined(__VISUALC__) && (__VISUALC__ >= 1200) __forceinline #endif - void Unlock() { if ( !IsEmpty() && --nRefs == 0) free(this); } + 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) + // we must not inline deallocation since allocation is not inlined + void Free(); // if we had taken control over string memory (GetWriteBuf), it's // intentionally put in invalid state diff --git a/src/common/string.cpp b/src/common/string.cpp index 791c5ce049..d0b3facc6b 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -160,6 +160,15 @@ wxSTD ostream& operator<<(wxSTD ostream& os, const wxString& str) #define STATISTICS_ADD(av, val) #endif // WXSTRING_STATISTICS +// =========================================================================== +// wxStringData class deallocation +// =========================================================================== + +void wxStringData::Free() +{ + free(this); +} + // =========================================================================== // wxString class core // ===========================================================================