Don't leak iconv handle

This commit is contained in:
baldurk
2017-09-01 17:58:54 +01:00
parent 5c4e21d6b5
commit f8d7043ad0
6 changed files with 23 additions and 0 deletions
+2
View File
@@ -389,6 +389,8 @@ RenderDoc::~RenderDoc()
Network::Shutdown();
Threading::Shutdown();
StringFormat::Shutdown();
}
void RenderDoc::Shutdown()
+2
View File
@@ -331,6 +331,8 @@ namespace StringFormat
void sntimef(char *str, size_t bufSize, const char *format);
string Wide2UTF8(const std::wstring &s);
void Shutdown();
};
// utility functions, implemented in os_specific.cpp, not per-platform (assuming standard stdarg.h)
@@ -101,6 +101,10 @@ string Wide2UTF8(const std::wstring &s)
RDCFATAL("Converting wide strings to UTF-8 is not supported on Android!");
return "";
}
void Shutdown()
{
}
};
namespace OSUtility
@@ -117,6 +117,10 @@ string Wide2UTF8(const std::wstring &s)
RDCFATAL("Converting wide strings to UTF-8 is not supported on Apple!");
return "";
}
void Shutdown()
{
}
};
namespace OSUtility
@@ -294,6 +294,13 @@ iconv_t iconvWide2UTF8 = (iconv_t)-1;
// before creating a temporary iconv_t, or hold two iconv_ts, or something.
Threading::CriticalSection lockWide2UTF8;
void Shutdown()
{
SCOPED_LOCK(lockWide2UTF8);
iconv_close(iconvWide2UTF8);
iconvWide2UTF8 = (iconv_t)-1;
}
string Wide2UTF8(const std::wstring &s)
{
// include room for null terminator, assuming unicode input (not ucs)
+4
View File
@@ -659,6 +659,10 @@ void sntimef(char *str, size_t bufSize, const char *format)
}
}
void Shutdown()
{
}
string Wide2UTF8(const wstring &s)
{
int bytes_required = WideCharToMultiByte(CP_UTF8, 0, s.c_str(), -1, NULL, 0, NULL, NULL);