diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:12:46 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:12:46 +0200 |
commit | b338e29fd3eaf700f8c8360aa0310048ba941d54 (patch) | |
tree | 122f8ef3790d12cd10275ef7453a9e8053322d78 /shared/dll_loader.cpp | |
parent | 3.18 (diff) | |
download | FreeFileSync-b338e29fd3eaf700f8c8360aa0310048ba941d54.tar.gz FreeFileSync-b338e29fd3eaf700f8c8360aa0310048ba941d54.tar.bz2 FreeFileSync-b338e29fd3eaf700f8c8360aa0310048ba941d54.zip |
3.19
Diffstat (limited to 'shared/dll_loader.cpp')
-rw-r--r-- | shared/dll_loader.cpp | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/shared/dll_loader.cpp b/shared/dll_loader.cpp index e942a168..029cabc5 100644 --- a/shared/dll_loader.cpp +++ b/shared/dll_loader.cpp @@ -20,20 +20,18 @@ public: HMODULE getHandle(const std::wstring& libraryName) { - HandleMap::const_iterator foundEntry = handles.find(libraryName); - if (foundEntry == handles.end()) - { - if (libraryName.empty()) - return ::GetModuleHandle(NULL); //return handle to calling executable + if (libraryName.empty()) + return ::GetModuleHandle(NULL); //return handle to calling executable - HMODULE newHandle = ::LoadLibrary(libraryName.c_str()); - if (newHandle != NULL) - handles.insert(std::make_pair(libraryName, newHandle)); + HandleMap::const_iterator iter = handles.find(libraryName); + if (iter != handles.end()) + return iter->second; - return newHandle; - } - else - return foundEntry->second; + HMODULE newHandle = ::LoadLibrary(libraryName.c_str()); + if (newHandle != NULL) + handles.insert(std::make_pair(libraryName, newHandle)); + + return newHandle; } private: @@ -56,11 +54,7 @@ private: FARPROC util::loadSymbol(const std::wstring& libraryName, const std::string& functionName) { const HMODULE libHandle = DllHandler::getInstance().getHandle(libraryName); - - if (libHandle != NULL) - return ::GetProcAddress(libHandle, functionName.c_str()); - else - return NULL; + return libHandle != NULL ? ::GetProcAddress(libHandle, functionName.c_str()) : NULL; } |