diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:15:39 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:15:39 +0200 |
commit | d2854834e18443876c8f75e0a7f3b88d1d549fc4 (patch) | |
tree | e967b628081e50abc7c34cd264e6586271c7e728 /zen/zstring.cpp | |
parent | 4.1 (diff) | |
download | FreeFileSync-d2854834e18443876c8f75e0a7f3b88d1d549fc4.tar.gz FreeFileSync-d2854834e18443876c8f75e0a7f3b88d1d549fc4.tar.bz2 FreeFileSync-d2854834e18443876c8f75e0a7f3b88d1d549fc4.zip |
4.2
Diffstat (limited to 'zen/zstring.cpp')
-rw-r--r-- | zen/zstring.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/zen/zstring.cpp b/zen/zstring.cpp index 5331499f..a559f9de 100644 --- a/zen/zstring.cpp +++ b/zen/zstring.cpp @@ -6,7 +6,7 @@ #include "zstring.h" #include <stdexcept> -#include <boost/thread/once.hpp> +#include <zen/stl_tools.h> #ifdef FFS_WIN #include "dll.h" @@ -55,14 +55,14 @@ LeakChecker& LeakChecker::instance() //caveat: function scope static initialization is not thread-safe in VS 2010! => make sure to call at app start! namespace { -struct Dummy { Dummy() { LeakChecker::instance(); }} blah; +const LeakChecker& dummy = LeakChecker::instance(); } std::string LeakChecker::rawMemToString(const void* ptr, size_t size) { std::string output = std::string(reinterpret_cast<const char*>(ptr), size); - output.erase(std::remove(output.begin(), output.end(), 0), output.end()); //remove intermediate 0-termination + vector_remove_if(output, [](char& c) { return c == 0; }); //remove intermediate 0-termination if (output.size() > 100) output.resize(100); return output; @@ -102,15 +102,13 @@ typedef int (WINAPI* CompareStringOrdinalFunc)(LPCWSTR lpString1, LPCWSTR lpString2, int cchCount2, BOOL bIgnoreCase); -SysDllFun<CompareStringOrdinalFunc> ordinalCompare; //caveat: function scope static initialization is not thread-safe in VS 2010! -boost::once_flag initCmpStrOrdOnce = BOOST_ONCE_INIT; +const SysDllFun<CompareStringOrdinalFunc> ordinalCompare = SysDllFun<CompareStringOrdinalFunc>(L"kernel32.dll", "CompareStringOrdinal"); } int z_impl::compareFilenamesWin(const wchar_t* a, const wchar_t* b, size_t sizeA, size_t sizeB) { - boost::call_once(initCmpStrOrdOnce, []() { ordinalCompare = SysDllFun<CompareStringOrdinalFunc>(L"kernel32.dll", "CompareStringOrdinal"); }); - + //caveat: function scope static initialization is not thread-safe in VS 2010! if (ordinalCompare) //this additional test has no noticeable performance impact { const int rv = ordinalCompare(a, //pointer to first string |